|
From: worlman385 on 7 Feb 2007 15:59 for the code below i got error at line 14 if ( $string1 gt $string2 ) print "$string1 $string2"; what's the problem? thanks print "Enter the first string: "; $string1 = <STDIN>; print "Enter the second string: "; $string2 = <STDIN>; chomp $string1; chomp $string2; if ( $string1 gt $string2 ) print "$string1 $string2"; elsif ( $string1 lt $string2 ) print "$string2 $string1"; elsif ( $string1 eq $string2 ) print "$string1\n$string2"; exit;
From: FeelLikeANut on 7 Feb 2007 16:12 On Feb 7, 3:59 pm, worlman...(a)yahoo.com wrote: > for the code below i got error at line 14 > if ( $string1 gt $string2 ) > print "$string1 $string2"; > > what's the problem? > > thanks > > print "Enter the first string: "; > $string1 = <STDIN>; > print "Enter the second string: "; > $string2 = <STDIN>; > > chomp $string1; > chomp $string2; > > if ( $string1 gt $string2 ) > print "$string1 $string2"; > elsif ( $string1 lt $string2 ) > print "$string2 $string1"; > elsif ( $string1 eq $string2 ) > print "$string1\n$string2"; > > exit; Perl requires curly braces around even one-lined if statements. if ( $string1 gt $string2 ) { print "$string1 $string2"; }
From: John Bokma on 7 Feb 2007 17:01 worlman385(a)yahoo.com wrote: > for the code below i got error at line 14 > if ( $string1 gt $string2 ) > print "$string1 $string2"; > > what's the problem? You not posting the exact error message... -- John Installing DBD-mysql with ActiveState Perl http://johnbokma.com/perl/installing-dbd-mysql-active-state.html
From: Petr Vileta on 7 Feb 2007 18:19 <FeelLikeANut(a)gmail.com> p�se v diskusn�m pr�spevku news:1170882776.455847.266120(a)l53g2000cwa.googlegroups.com... > On Feb 7, 3:59 pm, worlman...(a)yahoo.com wrote: >> for the code below i got error at line 14 >> if ( $string1 gt $string2 ) >> print "$string1 $string2"; >> > > Perl requires curly braces around even one-lined if statements. > > if ( $string1 gt $string2 ) { > print "$string1 $string2"; > } > Or you can use reverse IF syntax print "$string1 $string2" if ( $string1 gt $string2 ); -- Petr Vileta, Czech republic (My server rejects all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)
|
Pages: 1 Prev: find lines in a file Next: More Multiple Classes per File (was Pretty Format...) |