Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^7: Naming file handles with variables?

by QM (Parson)
on May 04, 2009 at 20:44 UTC ( [id://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 );

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-03-29 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found