Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

RE: Load file into a scalar without File::Slurp

by merlyn (Sage)
on Jun 28, 2000 at 23:32 UTC ( #20239=note: print w/ replies, xml ) Need Help??


in reply to Load file into a scalar without File::Slurp

I just go:

my $contents = do { local $/; <HANDLE> };
The $/ variable is not per-filehandle, so no need to select.

-- Randal L. Schwartz, Perl hacker


Comment on RE: Load file into a scalar without File::Slurp
Select or Download Code
Replies are listed 'Best First'.
RE: RE: Load file into a scalar without File::Slurp
by BlueLines (Hermit) on Jun 29, 2000 at 01:15 UTC
    rock on. it's nice to try to share an easy way to do something and end up with an even easier way in return :-)

    --jon
RE: RE: Load file into a scalar without File::Slurp
by matthew (Acolyte) on Jul 14, 2000 at 20:58 UTC
    Try this on for size...

    <xmp> my $content = join"",<FILEHANDLE>; </xmp>

    oooh, I get goosebumps...

    -Matthew
      But now you've built an array just to discard it when you create the string. So, you win points for "easy to type", but lose points for "wasteful implementation".

      -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-30 17:54 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 (273 votes), past polls