It's also interesting to note how undefined and null string values are handled as hash keys.
my %hash; my $a = undef; my $b = ''; $hash{$a} = 'foo'; print "$hash{$a}\n"; print "$hash{$b}\n"; <code> <p>Of course both these throw a warning. <code> C:\temp>hash.pl Use of uninitialized value in hash element at C:\temp\hash.pl line 8. Use of uninitialized value in hash element at C:\temp\hash.pl line 9. foo foo
It turns out I didn't really understand autovivification as well as I thought I did. Thanks for the node.
TGI says moo
In reply to Re: "A meditation on Hashes", or "Why i need more aspirin"
by TGI
in thread "A meditation on Hashes", or "Why i need more aspirin"
by EvanK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |