On Mon, 28 Jan 2002 10:19:56 +0100, Bart Lateur wrote:
>On Sun, 27 Jan 2002 12:34:55 -0500, Bill -OSX- Jones wrote:
>
>>Isn't there another var that is the same as STDERR ?
>>
>>And can't you set $! directly, and when printed - goed to STDERR ???
>
>I'll tell ya -- after the game closes. Which should be... in 14 hours?
OK, here it is: warn() will only attach a string " at foo.pl line nn"
plus a newline to its warning string *only if the string didn't end in a
newline*. This prevents accumulation of multiple such attachments when
you nest warn/die calls, e.g. when the error messages comes out of $@
after an eval(), or in a sub attached to $SIG{__WARN__}.
$a = $b = 0;
my $c = eval { $a/$b };
print "ERROR: ($@)\n";
warn $@;
print "OK\.\n";
This prints:
ERROR: (Illegal division by zero at test.pl line 3.
)
OK.
at STDOUT and
Illegal division by zero at test.pl line 3.
at STDERR.
Note how $@ already ended in a newline, thus $@ and the final warning
are identical.
--
Bart.