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

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

by audreyt (Hermit)
on Jul 24, 2000 at 21:25 UTC ( [id://24191]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

I usually use this Perl Golf-ish subroutine that doesn't require a filehandle:
$contents=slurp('foobar'); sub slurp {local$/=<>if local@ARGV=@_}
or use an in-line block:
{local$/;$contents=<>if local@ARGV='foobar'};
or, if you could afford a filehandle and wasted CPU time:
$contents=join'',<_>if open _,'foobar';
Of course, if this is really a Perl Golf contest entry, I'll probably write:
$contents=`cat foobar`
But it's platform dependent and cheating, so don't do that. :-p

/Autrijus/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://24191]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.