in reply to Tricking a filename argument to use STDOUT
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tricking a filename argument to use STDOUT
by cazz (Pilgrim) on Jun 27, 2005 at 21:41 UTC |