Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

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?
[Corion]: I think I saw virtualsue more recently in person than online :-D
[virtualsue]: It's true that there was a bigger gap between the 2 yr old post and the one before it
[ambrus]: yes, I probably just didn't see you two years ago, because I'm not in perlmonks much
[virtualsue]: Nor am I :-)
[talexb]: virtualsue Heh .. long time no see! :)
[virtualsue]: I have a quiet Perl themed slack workspace
[virtualsue]: The person who talks to me on it the most *hates* Perl but she hates everything

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2017-09-26 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (295 votes). Check out past polls.

    Notices?