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?