Other people have already posted reasonable solutions so I'll concentrate on the meta-problem here.

You keep posting questions like this, "I have file of format x with data y and I need to sort/count/total/modify it in way z". I think what you really need to do is likely to involve getting a book on SQL and installing a database. All these problems could have been solved in much more effective ways using simple SQL statements.

In this particular instance, what the poor monks responding to your question took 10+ lines to do could be done in one:

select n2.name,count(*) from datastore as n1, datastore as n2 where n2 +.name=n1.name and n2.yearmonth=200207 and n1.yearmonth<200207 group b +y n2.name;

Databases really come into their own with tabular data like this and if you're working with it a lot I *highly* recommend getting the necessary books, reading the online tutorials and installing one of the freely available RDBMSs (MySQL, PostGreSQL). That way the only thing you'll have to get perl to do is load the data in, from there you can play to your hearts content.


In reply to Re: Searching Files by PhiRatE
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.