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";