
y2k
New User
Jan 17, 2003, 5:36 AM
Post #1 of 3
(258 views)
|
|
need help with next statement
|
Can't Post
|
|
I'm a newbie to perl so go easy!! What does the next statement do? The following code is ain a book I'm reading right now:
for($i=0, $i <100, $i++) { next if(not $i % 2); print "An odd number is $i"; } The paragraph underneath says that this will print all the even numbers between 0 & 98 - but the print statement says otherwise!! So I'm confused. I know what the for statement is doing. And the if is saying if the modulus of $i divided by 2 is 0 return true else, return false (values are reversed because of the "not"). However, is the next saying "if the if statement evaluates to tru, then continue with the remainder of the statements withint the {}" or is it saying "if the if statement is true, then go onto the next iteration of the for loop"? Hope this doesn't sound confusing?
|