Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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?
[LanX]: I can't hear the word inquisition without Mel Brooks jumping in front of my inner eye
[LanX]: what a show
[erix]: yeah, I found that -- that's pretty good :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2017-01-18 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (159 votes). Check out past polls.