Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^7: Naming file handles with variables?

by QM (Parson)
on May 04, 2009 at 20:44 UTC ( #761800=note: print w/replies, xml ) Need Help??

in reply to Re^6: Naming file handles with variables?
in thread Naming file handles with variables?

I like the map idea, though I'd probably end up with a subroutine. Here's what I find myself doing:
sub open_for_write { my @filenames = @_; my @fh; # or my %fh; for my $fn (@filenames) { my $fh; # does it exist? # is it zipped? # open for append? # open with create? $fh[@fh] = $fh; # wink, wink # or $fh{$fn} = $fh; } return @fh; # or return \%fh; ############ my @filehandles = open_for_write( @filenames ); # or my $filehandles_hashref = open_for_write( @filenames );

Quantum Mechanics: The dreams stuff is made of

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2016-10-26 15:58 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (344 votes). Check out past polls.