programming-examples/perl/Statement/The last statement breaks out of a loop from within the loop block.pl

10 lines
143 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
$n=0;
while( $n < 10 ){
print $n;
if ($n == 3){
last; # Break out of loop
}
$n++;
}
print "Out of the loop.<br>";