in reply to Re: Unique value count in hash not working properly
in thread Unique value count in hash not working properly
- Assignment, bar key is assigned the value 1
- my %foo; $foo{bar} = 1;
Autovivification, a hashref springs into existence under key fa , bar key is assigned the value 1
- my %foo; $foo{fa}{bar} = 1;
Autovivification, you use it as a reference to a hash, , it becomes a reference to a hash
- my $foo; $foo->{bar} = 1;
Autovivification, you use it as a reference to an array, it becomes a reference to an array
- my $foo; $foo->[0]= 1;
Initialization, you declare $foo and assign a reference, you can use it as a reference, but it doesn't become a reference, because it already is a reference
- my $foo = {}; $foo = \my %bar; $foo->{fa} = 1;
Error, can only autovivify if undef, Not an ARRAY reference
- my $foo = {}; $foo->[0] = 1;
Error, can only autovivify once, Not a HASH reference
- my $foo; $foo->[0] = 'autovivified'; $foo->{autovivified} = 'already';
|
---|
In Section
Seekers of Perl Wisdom