I'm trying to organize some data into one structure for reporting. I collate the data from parsing emails.
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...
(
siteA => ('10-9-11' => 3,
'11-9-11' => 1,
'12-9-11' => 2),
siteB => ('04-04-11' =>5,
'05-05-11' =>1)
)
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.
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'
...
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.