Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: filehandler stored in hash-ref

by kyle (Abbot)
on Dec 10, 2009 at 15:25 UTC ( #812218=note: print w/ replies, xml ) Need Help??


in reply to filehandler stored in hash-ref

You can get the print to work if you wrap the filehandle in a block.

my $s = {} ; open $s->{out}, '>', 'out' or die "open: $!\n"; print { $s->{out} } "test"; close $s->{out} or die "close: $!\n";

Note that if you're reading from a filehandle in an array, you have to store it in a scalar for the diamond operator to work.

my $fh = $s->{in}; my $line = <$fh>;

If that's too much trouble, you can use readline.


Comment on Re: filehandler stored in hash-ref
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2015-07-28 03:33 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 (252 votes), past polls