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.
|