Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: put file content into a string

by Hue-Bond (Priest)
on Dec 19, 2005 at 16:19 UTC ( [id://517781]=note: print w/replies, xml ) Need Help??


in reply to put file content into a string

Of course, more than one. Try:

{ local $/ = undef; open my $fd, '<', 'file' or die "open: $!"; my $txt = <$fd>; close $fd; }

Or:

open my $fd, '<', '/home/hue/f1' or die "open: $!"; my $txt = join '', <$fd>; close $fd;

Be sure to take a look at perldoc perlop for insights on this and many other subjects.

--
David Serrano

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://517781]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found