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 );