Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928964]
help
Chatterbox?
[stevieb]: I have got ready everything in a stable manner to go forward with a full-blown "Raspberry Pi with Perl" series, and at the same time "Automated testing locally for everything" series. A year it took. A year I've been waiting to do this.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-06-29 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (653 votes). Check out past polls.