Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Which way is recommended ?

by matrixmadhan (Beadle)
on Nov 21, 2008 at 19:15 UTC ( [id://725210]=note: print w/replies, xml ) Need Help??


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

Thanks

I should not have used the term 'directly' which means in any case with respect to $_; but that's not how it works.

Too impressive. :)

Replies are listed 'Best First'.
Re^3: Which way is recommended ?
by TGI (Parson) on Nov 22, 2008 at 02:19 UTC

    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?
Username:
Password:

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

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

    No recent polls found