Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2016-10-28 22:50 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (387 votes). Check out past polls.