Following #2 in Basic debugging checklist, I would recommend printing out the hash after every time you assign to a key or subkey of your %metrics hash. Because it's a complex structure, use Data::Dumper, as:

use Data::Dumper; ... # after some assignment like $metrics{$product}{$date} = $day; print STDERR Dumper \%metrics; $metrics{$product}{$date}{$hour}{$user} = $val; print STDERR Dumper \%metrics;

as a one liner, with hardcoded values, for the first assignment and print:

C:\usr\local\share\PassThru\perl>perl -MData::Dumper -le "$metrics{pro +duct}{today} = 'Wed'; print STDERR Dumper \%metrics" $VAR1 = { 'product' => { 'today' => 'Wed' } };

You might then notice that at the first print, the value of the 'today' key is a string, 'Wed', and not another { nested => hash }. With a string as the value of {today}, you cannot take another subkey (like {today}{12}), because strings don't have subkeys. I think you need to rethink your data structure. Maybe show us in the Data::Dumper-like notation printed above, what you do want your data to look like when you're done, and we can help you organize your data into that format.


In reply to Re^3: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use by pryrt
in thread Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use by 5NOMAD7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.