A
Alan Curry
I accidentally wrote this:
my $v = 12345; # really some input, verified to be neither 0 nor undef
# a few lines later...
my $str = sprintf "%06x\n". $v;
The warning actually made it harder to find the bug because it told me
something that wasn't true.
$ perl -we 'my $v = 12345; my $str = sprintf "%06x\n". $v;'
Use of uninitialized value $v in sprintf at -e line 1.
Wondering where and how $v became undef, I threw in some
defined($v) or die;
statements, and none of them died, including the one immediately before the
sprintf line with the warning, but still the warning said that $v was
"uninitialized", which I know really means undef.
Do you see the typo? That's not a comma.
The warning message accused an innocent bystander of being undefined.
my $v = 12345; # really some input, verified to be neither 0 nor undef
# a few lines later...
my $str = sprintf "%06x\n". $v;
The warning actually made it harder to find the bug because it told me
something that wasn't true.
$ perl -we 'my $v = 12345; my $str = sprintf "%06x\n". $v;'
Use of uninitialized value $v in sprintf at -e line 1.
Wondering where and how $v became undef, I threw in some
defined($v) or die;
statements, and none of them died, including the one immediately before the
sprintf line with the warning, but still the warning said that $v was
"uninitialized", which I know really means undef.
Do you see the typo? That's not a comma.
The warning message accused an innocent bystander of being undefined.