Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };

by skillet-thief (Friar)
on Aug 31, 2003 at 06:22 UTC ( #287987=note: print w/ replies, xml ) Need Help??


in reply to Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };

Maybe I'm missing something. Besides basic coolness, and getting it down to one line, I don't understand the specific advantage of using "do" as opposed to how I usually slurp:
my $string; { local $/ = undef; $string = <FH>; }
That said, I do like the way the proposed idiom looks.

Cheers,
s-t
  • Comment on Re: Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2016-06-29 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (370 votes). Check out past polls.