develooper Front page | perl.perl5.porters | Postings from May 2003

Re: Proposal: include var name in 'use of undefined value' warning

Thread Previous
From:
Claes Jacobsson
Date:
May 9, 2003 18:28
Subject:
Re: Proposal: include var name in 'use of undefined value' warning
Message ID:
DD6D2630-8286-11D7-BD57-000393C12F9E@surfar.nu
On lördag, maj 10, 2003, at 00:41 Europe/Stockholm, Dave Mitchell wrote:

> Currently, code like the following produces the warning shown:
>
>     $ perl -wle 'my $x=1; my $y; print $x+$y'
>     Use of uninitialized value in addition (+) at -e line 1.
>     1
>
> When the code is more complicated, it becomes very irritating that
> Perl doesn't tell you the name of the variable that had the undef 
> value.
>
> I include a proof-of-concept patch below (not to be applied !!!!)
> that produces the following warning instead:
>
>     Use of uninitialized variable $y in addition (+) at -e line 1.

IMHO, the message should read "Use of uninitialized value $y in 
addition (+) at -e line 1." instead, since there might be folks out 
there who as a __WARN__ signal handles that looks for "Use of 
initialized value" in the warning.

/Claes J.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About