No such thing as a small change | |
PerlMonks |
use IO qw(File Handle); my $io = do { if (shift) { my $tmp = IO::Handle->new; die "open failed: $!" unless $tmp->fdopen(fileno(STDOUT),"w"); $tmp; } else { my $tmp = IO::File->new('tmp.out', 'w'); $tmp; } }; $io->print("Some text\n");
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: output to STDOUT or a file
by bv (Friar) on Sep 04, 2009 at 18:12 UTC |