If I try running the following:
then I get the expected result:#!/usr/bin/perl -w use Data::Dumper; { my $hashref; $hashref->{'foo'} = "bar"; print Dumper($hashref); }
However, if I try to combined the my and the assignment on the same line, as in the following:[alex@home dev]$ perl -w hashref.pl $VAR1 = { 'foo' => 'bar' };
then Perl gives me an error:#!/usr/bin/perl -w use Data::Dumper; { my $hashref->{'foo'} = "bar"; print Dumper($hashref); }
This seems odd to me -- does this mean that there's a limit to what autovivification will do?[alex@home dev]$ perl -w hashref2.pl Can't use an undefined value as a HASH reference at hashref2.pl line 6 +.
The difference seems semantic to me. Please, pass me a clue by four.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
In reply to Using an undefined value as a hashref by talexb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |