In the first call Perl accepts passing an yet undefined hash value for the key "not_existing". E.g. you may want to populate it in foo!²
In the second call it warns about an undefined key. Keys are strings not undef which must be mapped to "".
Different things.
Cheers Rolf
( addicted to the Perl Programming Language)
¹) ah ok, now that I can test it's obvious why! Both warnings are for the second call. The first doesn't cause warnings.
²) demonstration of a legal use case
DB<102> sub populate { $_[0]="xxx" } DB<103> populate $hash{not_existent} => "xxx" DB<104> \%hash => { not_existent => "xxx" } DB<105> use warnings; populate $hash{+ undef} Use of uninitialized value in hash element at ...
In reply to Re: Inconsistency of 'Use of uninitialized value in scalar assignment' warning
by LanX
in thread Inconsistency of 'Use of uninitialized value in scalar assignment' warning
by ccn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |