http://qs321.pair.com?node_id=857700


in reply to Printing to a File from Sub

Of course, if your code is OO you could also store the filehandle in the object to prevent the need for passing it around, even better create a method to retrieve the fh that created it on the first request. Perl filehandles when create as Corion exhibited can be passed around like any scalar, pretty much. Or you could even create a closure to handle all prints:
{ my $fh; open($fh,'>',$file); sub print_to_fh { print $fh @_; } }
As always, TIMTOWTDI :)

                - Ant
                - Some of my best work - (1 2 3)