llancet has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks!
For some reason, I want to open several files for write, and seek those output handles by their name:
my %handles; while (<IN>) { my $file_out = get_the_way_out($_); my @some_data = get_the_data($_); if (!exists $handles{$file_out}) { open my $handle,'>',$file_out or die $!; $handles{$file_out} = $handle; } # but this is not allowed say $handles{$file_out} join "\t",@some_data; } close $_ foreach values %handles;
How can I properly organize my handles? Thanks for a lot!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: store file handles in a hash
by Athanasius (Archbishop) on Oct 30, 2012 at 14:14 UTC | |
|
Re: store file handles in a hash
by trwww (Priest) on Oct 30, 2012 at 16:23 UTC |