From: Thomas Bätzler <[email protected]>
> Taylor, Andrew (ASPIRE) <[email protected]> wrote:
> > I'm processing a file of test data that looks something like:
> >
> > FH1,data1,data2,data3,...etc
> > FH2,data1,data2,data3,...etc
> > FH1,data1,data2,data3,...etc
> >
> > Each line split into an array and processed.
> >
> > The first element (FH1, FH2, etc) is the name of the filehandle the
> > output should be printed to.
> [...]
>
> Try
>
> my %fh;
>
> open( $fh{'FH1'}, '>', $somefile ) or die "Can't open $somefile: $!";
> ...
>
> print $fh{'FH1'} "$output\n";
print {$fh{'FH1'}} "$output\n";
If the filehandle is a more complex expression than a bareword or
simple variable you have to enclose it in curlies so that perl knows
it's meant to the the optional filehandle and not the thing to print.
Jenda
===== [email protected] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/