in reply to Redirect Subroutine Output
my $out_fh; if ($to_file) { open($out_fh, '>', ...) or die(...); } else { $out_fh = \*STDOUT; } ... print $out_fh "blah\n";
You can also change the default handle:
if ($to_file) { open(my $out_fh, '>', ...) or die(...); select($out_fh); } ... print "blah\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Redirect Subroutine Output
by spickles (Scribe) on Aug 26, 2009 at 17:30 UTC | |
by ikegami (Patriarch) on Aug 26, 2009 at 17:37 UTC | |
by spickles (Scribe) on Aug 26, 2009 at 18:23 UTC | |
by ikegami (Patriarch) on Aug 26, 2009 at 18:43 UTC |