Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Answer: How do I read an entire file into a string?

by vroom (Pope)
on Jan 11, 2000 at 02:28 UTC ( #1953=categorized answer: print w/replies, xml ) Need Help??

Q&A > files > How do I read an entire file into a string? - Answer contributed by vroom

Unset $/, the Input Record Separator, to make <> give you the whole file at once.
{ local $/=undef; open FILE, "myfile" or die "Couldn't open file: $!"; $string = <FILE>; close FILE; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-06-26 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (583 votes). Check out past polls.