Jun 25, 2006 #1 sedawk Programmer Joined Feb 5, 2002 Messages 247 Location US I want print an arithmetic equation in a print command, for example. Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is " . $i . "and the next one is " . $i+1; } But the compiler produced an error about arithmetic operation. How to do that? Thanks
I want print an arithmetic equation in a print command, for example. Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is " . $i . "and the next one is " . $i+1; } But the compiler produced an error about arithmetic operation. How to do that? Thanks
Jun 25, 2006 #2 brigmar Programmer Joined Mar 21, 2006 Messages 414 Location US Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is " . $i . " and the next one is " . ($i+1)."\n"; } Upvote 0 Downvote
Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is " . $i . " and the next one is " . ($i+1)."\n"; }
Jun 25, 2006 Thread starter #3 sedawk Programmer Joined Feb 5, 2002 Messages 247 Location US Thanks. Upvote 0 Downvote
Jun 25, 2006 #4 KevinADC Technical User Joined Jan 21, 2005 Messages 5,070 Location US just a twist on how to do this: Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is $i and the next one is @{[$i+1]}\n"; } Upvote 0 Downvote
just a twist on how to do this: Code: for (my $i = 0 ; $i < 4; $i++){ print "the number is $i and the next one is @{[$i+1]}\n"; }