Hi -- in the interest of helping you help yourself I would suggest you break up the problem into subproblems.

  1. Read in this month's file and use the split function to find the first word on each line, then update a hash, using that first word as the key.
  2. Determine the name of the file for each of the previous three months (sort of tricky -- think about in February 2003 -- you need to get 200211, 200212, and 200301).
  3. For each of those files:
    • create a new hash, let's call it the "counter" hash
    • read in each record and split to find the first word.
    • if the word is in the "this month" hash, increment your counter hash.
    • when you're done reading a given file, print out the counter hash.
Each of these subproblems is pretty simple on its own, so start there and report back if you're struggling.

In reply to break up the problem by cebrown
in thread Searching Files by rchou2

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.