Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

(tye)Re: Slurp a file

by tye (Sage)
on Jan 08, 2001 at 21:56 UTC ( [id://50533]=note: print w/replies, xml ) Need Help??


in reply to Slurp a file

You need to check whether open fails and report a useful error. Here is a trick to do that for you:

my $contents= do { local(*ARGV,$/); @ARGV="myfile.txt"; <> };
Though I'm taking on faith that local(*ARGV) will properly save and restore everything that <> manipulates. (:

        - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

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

    No recent polls found