in reply to Can a while loop be stopped with "last"?

It might have been faster to try it yourself than to type in the question:
perl -e 'while (1) { if (1) { last } }'
The above code does not run forever. Question answered!
rjbs

Replies are listed 'Best First'.
Re^2: Can a while loop be stopped with "last"?
by beable (Friar) on Jul 14, 2004 at 02:45 UTC
    It might have been even faster to look up the documentation for last with perldoc -f last, or here: perlfunc. Look at the example! It's got a while loop with last breaking out of it.

    # example from perldoc -f last LINE: while (<STDIN>) { last LINE if /^$/; # exit when done with header #... }