in reply to Re: Initializing Hash Arrays in Perl
in thread Initializing Hash Arrays in Perl
1. If $REFERRERS is not yet defined, it will automagically become a hashref ... [emphasis added]
A small but, IMO, important point: In the case cited (and if strictures were not enabled; see strict), a hash named %REFERRERS of the package global flavor would be autovivified, not a hash reference. A hash reference would be created if the -> operator were used (see perlop).
c:\@Work\Perl>perl -w -MData::Dump -le "$REFERRERS{foo}{bar}{baz}++; ;; dd \%REFERRERS; " { foo => { bar => { baz => 1 } } } c:\@Work\Perl>perl -w -MData::Dump -le "$REFERRERS->{foo}{bar}{baz}++; ;; dd $REFERRERS; " { foo => { bar => { baz => 1 } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Initializing Hash Arrays in Perl
by winterwind (Initiate) on Feb 14, 2014 at 19:01 UTC |