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

Re: filehandle for close

by eyepopslikeamosquito (Chancellor)
on Jan 14, 2013 at 21:05 UTC ( #1013279=note: print w/replies, xml ) Need Help??


in reply to filehandle for close

You need to lose the braces around the argument to close because Perl is interpreting that as an anonymous hash (as "use warnings" will tell you). This works for me:

use strict; use warnings; my %files; open $files{"foo"}, '>', "xyz" or die "open failed: $!"; print { $files{"foo"} } "done\n" or die "print failed: $!"; # close { $files{"foo"} }; # oops: 'Odd number of elements in anony +mous hash' close $files{"foo"}; # works ok

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013279]
help
Chatterbox?
[ambrus]: Corion: um, that was me (duh)
[ambrus]: I just can't get you two to cooperate directly because schmorp doesn't want to be in the chatterbox
[ambrus]: maybe you should join his irc channel or something, unless that causes a flame blowup

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2016-12-09 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (151 votes). Check out past polls.