Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by skillet-thief (Friar)
on Aug 31, 2003 at 06:22 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found