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 bdalzell (Sexton)
on Dec 28, 2011 at 22:36 UTC ( #945429=categorized answer: print w/replies, xml ) Need Help??

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

This is slightly different code for using File::Slurp:
use strict; use File::Slurp; my $text = read_file($file);
Be sure to read the "slurp_article", available in the distro under "Documentation" (i.e. under the "extras" directory).

And remember that if you cut and paste sample code from a web page, some of the punctuation characters may not be formatted for your system so if you get an error from cut and pasted code try typing it in directly to your program.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2018-03-17 11:52 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.