[Israel.pm] redirecting STDERR
Shlomi Fish
shlomif at iglu.org.il
Thu Jun 16 02:04:09 PDT 2005
On Thursday 16 June 2005 00:17, Gabor Szabo wrote:
> local *STDERR;
> open STDERR, ">", \$file or die $!;
> print STDERR "hello world\n";
This code does not work properly if you fork:
stderr.pl:
<<<
#!/usr/bin/perl
print STDERR "Hello!\n";
>>>
test-stderr.pl:
<<<
#!/usr/bin/perl
use strict;
use warnings;
my $file;
local *STDERR;
open STDERR, ">", \$file
or die $!;
system("perl stderr.pl");
print "\$file = <<<\n$file\n>>>";
>>>
Why? Because a filehandle that prints to a scalar is not a real UNIX
filehandle.
Regards,
Shlomi Fish
---------------------------------------------------------------------
Shlomi Fish shlomif at iglu.org.il
Homepage: http://www.shlomifish.org/
Tcl is LISP on drugs. Using strings instead of S-expressions for closures
is Evil with one of those gigantic E's you can find at the beginning of
paragraphs.
More information about the Perl
mailing list