programming-examples/perl/Statement/Using the next statement in a foreach structure.pl
2019-11-15 12:59:38 +01:00

12 lines
265 B
Perl

foreach ( 1 .. 10 ) {
if ( $_ == 5 ) {
$skipped = $_; # store skipped value
next; # skip remaining code in loop only if $_ is 5
}
print "$_ ";
}
print "\n\nUsed 'next' to skip the value $skipped.\n";