Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^3: Which way is recommended ?

by TGI (Parson)
on Nov 22, 2008 at 02:19 UTC ( #725275=note: print w/replies, xml ) Need Help??

in reply to Re^2: Which way is recommended ?
in thread Which way is recommended ?

There is an implicit check for definedness when you do while (<FOO>) { }. See the perlop section on I/O Operators.

while (<FOO>) { # do stuff } # terminates if we get a line that evaluates to false. while (my $l = <FOO>) { # do stuff } # only terminates at end of file (or error reading file) while (defined(my $l = <FOO>)) { # do stuff } # Let's take advantage of $_ and be somewhat safe(r). { local $_; while (<FOO>) { # do stuff } }

TGI says moo

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://725275]
[Corion]: ambrus: Sorry for running out on you yesterday regarding the HTTP module discussion
[Corion]: I hope I'll find time to turn my quest(ion) into a SoPW ;)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2016-12-08 10:18 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (139 votes). Check out past polls.