Use Data::Dumper to print the hashes out so you can see what gets populated.

use Data::Dumper; print Dumper(\%agency);

That is also the weirdest nested hash syntax I have ever seen. I think it's supposed to look more like this:

$agency{$e4}->{$e7}->{$e6}++;

That change starts to create an interesting hash once it is printed with Data::Dumper. Give it a shot.

Addendum:

Other things I've noticed about your code.

  • In the nested hash example, where are you getting $pf from? Bad cut and paste from the OO version? Did you mean $e6?
  • You are not storing the agency in the first level of the hash(stored in $e3). You may need:
    $agency{$e3}->{$e4}->{$e7}->{$e6}++;
  • The way you are incrementing the counters is incorrect, you want to check those more closely so you get the correct results. Notice that you are storing the current value+1. What you probably wanted was to increment the value in the hash by one AND increment the cumulative count(which I assume the *_count variables are for).

  • In reply to Re: nested hashes or object oriented by pzbagel
    in thread nested hashes or object oriented by ctaustin

    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.