http://www.perlmonks.org?node_id=839960


in reply to writing in 2 handles

# Create an array of file handles my @fhs; for my $file (qw (gash1.txt gasg2.txt gash3.txt) { open (my $fh, '>', $file) or die "Unable to open $file: $!"; push @fhs, $fh } # Now for the print print $_ "Some stuff\n" for @fhs; print $_ "Some more stuff\n" for @fhs; # Close the files close $_ for @fhs;