> 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]
Yep, that works for me, but it doesn't work everywhere: [console] $ perl -e 'use warnings; $c=undef; printf("%s", $c->[0]{dog})' Use of uninitialized value in printf at -e line 1. [/console] Anything that can help me here? I wish it'd say: Use of uninitialized value $c->[0]{dog} in printf at -e line 1. ... but it doesn't. - Bryan -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/