Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Writing to a file handle not attached to a file?

by gellyfish (Monsignor)
on Oct 26, 2006 at 08:22 UTC ( #580706=note: print w/ replies, xml ) Need Help??


in reply to Writing to a file handle not attached to a file?

With a recent (i.e. 5.8.0 onward) perl you can simply open a filehandle to a reference to a scalar rather than a filename. E.g. :

my $foo = ""; + open BAR, '>', \$foo; + print BAR "Test test"; close BAR; + print $foo;
In older perls you might want to see IO::Scalar for instance.

/J\


Comment on Re: Writing to a file handle not attached to a file?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2015-07-03 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls