From: Thomas Bätzler <t.baetz...@bringe.com> > Taylor, Andrew (ASPIRE) <andrew.tayl...@hmrcaspire.com> 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 ===== je...@krynicky.cz === 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/