thor has asked for the wisdom of the Perl Monks concerning the following question:
When I try to use $fh{$record[0]} directly, perl complains about syntax errors. My work around works, but I somehow feel dirty afterwards. Is there something that I'm missing?my %fh; while(<>) { my @record = split; $fh{$record[0]} || open($fh{$record[0]}); my $fh = $fh{$record[0]}; print $fh $_; }
Thanks in advance,
thor
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash values as filehandles
by jmcnamara (Monsignor) on Apr 30, 2004 at 18:41 UTC | |
|
Re: Hash values as filehandles
by chromatic (Archbishop) on Apr 30, 2004 at 18:57 UTC | |
|
Re: Hash values as filehandles
by blue_cowdawg (Monsignor) on Apr 30, 2004 at 18:42 UTC | |
|
Re: Hash values as filehandles
by ysth (Canon) on Apr 30, 2004 at 21:19 UTC |