Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

( #945429=categorized answer: print w/ replies, xml ) Need Help??

Q&A > files > How do I read an entire file into a string? 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.

Comment on Answer: How do I read an entire file into a string?
Download Code
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-08-29 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls