On Thursday 03 Jun 2010 19:53:48 Bryan R Harris wrote:
> Seems like the first time I run a new script I *always* get an error
> message something like this:
>
> "Use of uninitialized value in printf at /Users/harrisb/Library/perl/matc
> line 414."
>
> The problem is usually I'm printing several things, so I have no idea which
> variable wasn't initialized from that error. So I usually end up pulling
> all the variables apart onto separate lines with their own print commands.
>
> But I was just thinking -- why doesn't the error just tell me which
> variable was uninitialized? e.g. 'Variable "$count" used with
> uninitialized value in printf at /Users/harrisb/Library/perl/matc line
> 414.'
>
> That would save me so much time debugging! Is there a way to enable that
> somehow?
Such a feature exists in more recent versions of Perl:
[console]
shlomi:~$ perl -e 'use warnings; printf("%s", $c);'
Name "main::c" used only once: possible typo at -e line 1.
Use of uninitialized value $c in printf at -e line 1.
[/console]
I'm using 5.10.1 here (will be 5.12.x shortly after Cooker de-stabilises.)
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/