Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Unique value count in hash not working properly

by Anonymous Monk
on Oct 01, 2011 at 00:02 UTC ( #928964=note: print w/ replies, xml ) Need Help??


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';


Comment on Re^2: Unique value count in hash not working properly
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928964]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-04 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls