Since we haven't seen an example of the input file we have to make assumptions about how it looks. Then we have to derive solutions based on those assumptions.

Your solution is so elegant for a simple and small data set; why look for a Perlish solution when the easiest solution is simple OS grep? But there are a couple of pitfalls I see right off the bat. First, what if '1996' appears in a commentary portion of a filing record. I don't know what his SEC filings file looks like, but what if...

2/27/1996 - Noble Energy Corporation Based on a 1995 SEC request for information Noble Energy Corp (NE) sub +mits the following findings on its joint venture with Transocean Rese +arch for offshore rigs to be installed in the North Seas with a proje +cted completion date of 3Q 1997. ...

Of course we really don't know what the data set looks like, so your solution may be spot on. On the other hand, if general text starts looking like trigger dates, you've got a problem.

Secondly, your solution has to iterate over the file once for each year. If the input file isn't too large, 'who cares.' But if the input file is or may grow large, the simplest solution may turn out to be an inefficient one.

But if it turns out your take on the problem works, I actually like it the best since it keeps simple things simple. In a way, even though it doesn't use Perl, it's the most Perlish solution.


Dave


In reply to Re^2: Help with splitting one text file into other text files by davido
in thread Help with splitting one text file into other text files by eversuhoshin

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.