Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Can a while loop be stopped with "last"?

by rjbs (Pilgrim)
on Jul 14, 2004 at 02:40 UTC ( [id://374197]=note: print w/replies, xml ) Need Help??


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 #... }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://374197]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-19 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found