The /dev/fd/1 trick works on Linux:
use strict; use warnings; sub hello { my $filename = shift; open my $out, '>', $filename or die "Can't write to $filename: $!\n"; print $out "Hello world!\n"; close $out or die "Failure closing $filename: $!\n"; return; } hello( '/dev/fd/1' ); # use /dev/fd/1 as the filename for STDOUT print "Is STDOUT still open?\n"; __END__ Hello world! Is STDOUT still open?
the lowliest monk
In reply to Re: Tricking a filename argument to use STDOUT
by tlm
in thread Tricking a filename argument to use STDOUT
by fapestniegd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |