tags:

views:

78

answers:

1

Why doesn't Perl 5 give me the name of the variable it is complaining about?

perl5.8.9 -we 'my $u; print "$u\n"'
Use of uninitialized value in concatenation (.) or string at -e line 1.
+7  A: 

It has since version 5.10 which was released in 2007, it is time to upgrade (5.12.2 is coming out shortly).

perl5.10.0 -we 'my $u; print "$u\n"'
Use of uninitialized value $u in concatenation (.) or string at -e line 1.
Chas. Owens
yeah but why didn't it do it before that?
frankc
Silly answer: because the code wasn't written to do it yet. My best guess is that it wasn't seen as important. You could ask the same question about why we didn't have `strict` until Perl 5.
Chas. Owens
@user275455 Somebody had to have the knowledge and the time and the inclination to make it do that. Its non-trivial for Perl to figure out what triggered the warning as you can see by looking at the patch which implemented it. http://perl5.git.perl.org/perl.git/commit/29489e7c741791873ea464cb7e13d2b5a19577a7
Schwern