in reply to passing Dumper output to print subroutine?
You mean something like:
use Data::Dumper; use Fatal qw(open close); open my $log, '>', $path_to_log; my_print_routine( $log, Dumper( \%some_var ) );
Update ... I imagine your subroutine just uses print, with no room for specifying a filehandle. Something like:
<code> sub my_print_routine { print for @_; print "\n"; }You could select your filehandle to make it the default output, but that doesn't work if you also print to STDOUT. You could modify the print routine to check whether the first arg is a filehandle, and select it there, saving the previous value to select it back at the routine exit.
P.S. Bareword fielhandles and two-argument open are so Perl4 ... check out 'perldoc -f open' for the modern way.
Update 2 ... I dunno about others, I would check the first arg by seeing if : 'GLOB' eq ref $_[0]. if you had a valid reason for passing around GLOBs, that would fail.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|