Let's decompose what you are doing:
foreach $id (sort keys %quantum) {
Okay, so $id contains a string which is also a key in %quantum. Next:
foreach $date ( sort ... keys %{$quantum{$applid}}) { }
Okay, now we're going to sort a bunch of keys from a contained hashref. I note that you have $applid instead of $id. Is this a typo, or is this some value imported from elsewhere? Ignoring this fact, your sort looks like:
sort { $a->{int(substr($quantum{$id},2,2))} <=> $b->{int +(substr($quantum{$id},2,2))} || $a->{int(substr($quantum{$id},0,2))} <=> $b->{int +(substr($quantum{$id},0,2))} }
The things being fed into your sort (your $a and $b) are the keys (strings), not the values (hash refs). You are trying to dereference the hash keys as hashes and thus your error. You likely meant
foreach my $id (sort keys %quantum) { foreach my $date ( sort { int(substr($quantum{$id}{$a},2,2)) <=> int(substr +($quantum{$id}{$b},2,2)) || int(substr($quantum{$id}{$a},0,2)) <=> int(substr +($quantum{$id}{$b},0,2)) } keys %{$quantum{$id}}) { } }
Or maybe no_slogan guessed better. In either case, see HASHES OF HASHES in perldsc, and maybe perlreftut to boot.

I'm also a little thrown as to why strict is not complaining about you not using my on your loop variables, but that's a different question.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: Can't use string as a HASH ref by kennethk
in thread Can't use string as a HASH ref by tentacoolstuff

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.