Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 avoiding work at the Monastery: (4)
As of 2015-07-28 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls