The next statement allows you to skip
past the rest of the enclosing block without killing the existing
loop. Looping continues like normal, you have only skipped part of
the enclosed block of instructions for this particular pass through
the loop.
The next statement works for the
for, foreach, while, until and naked blocks (blocks that have
put in manually that are not part of a larger block.
The next statement does not work
for the if and do while / until
blocks.
This is just like last .
Example:
# Sum all the even numbers entered
while ( $nextVar = <STDIN> )
{
chomp $nextVar;
if ( ! ($nextVar % 2) )
{
next;
}
$theSum += $nextVar;
}