Mega Code Archive
Using the last statement in a foreach structure
foreach ( 1 .. 10 ) {
if ( $_ == 5 ) {
$number = $_; # store current value before loop ends
last; # jump to end of foreach structure
}
print "$_ ";
}
print "\n\nUsed 'last' to terminate loop at $number.\n";