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