Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have multiple sites, siteA, siteB etc and for each site there are dates and some dates repeated (the number of times I want to report).
I decided to create a hash of sites and the hash value for each site to be a hash of dates and the number of occurences. Basically I want my data to look like this...
I can create the initial entries and new sites and increment the date counter but I'm having trouble adding new dates to the hash reference.( siteA => ('10-9-11' => 3, '11-9-11' => 1, '12-9-11' => 2), siteB => ('04-04-11' =>5, '05-05-11' =>1) )
Can someone please help me add a new hash date entry? I thought I could slice a hash reference but I can't get it working.my %h; # New site $h{'siteA'} = {'09-10-2011' => 1}; # Second instance of site and date found, increment. $a{'siteA'}->{'09-10-2011'}++; # Another date found for siteA, '10-10-2011' ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Adding to a hash reference
by Marshall (Canon) on Dec 08, 2011 at 13:26 UTC | |
|
Re: Adding to a hash reference
by tobyink (Canon) on Dec 08, 2011 at 12:48 UTC | |
|
Re: Adding to a hash reference
by Anonymous Monk on Dec 08, 2011 at 13:27 UTC | |
by Anonymous Monk on Dec 08, 2011 at 13:48 UTC |