Mega Code Archive

 
Categories / Perl / Statement
 

The last statement breaks out of a loop from within the loop block

$n=0; while( $n < 10 ){    print $n;    if ($n == 3){        last;  # Break out of loop    }    $n++; } print "Out of the loop.<br>";