I have a flat file example is below. I need to parse through the flat file looking for the numbers ranging from 4000 to 6200 and count up how many times it finds each of them and output the results to another file.
So how many times did it fine 4001 or 4348 or 5774?
Each line in the file will look like the following, I only want to count the ones that have the bn infront of the 4 digit number, and I don't want to count the digits if they happen to match after the word bytes.
Data Example:
base1,Thu 21Dec06 08:00:02 ,62bn6085, bytes 608584
base1,Thu 21Dec06 08:00:07 ,63bn5600, bytes 77383
base2,Thu 21Dec06 08:00:18 ,65bn6085, bytes 88373
base5,Thu 21Dec06 08:00:19 ,66bn6042, bytes 388377
base4,Thu 21Dec06 08:03:44 ,81bn4370, bytes 8956003
base6,Thu 21Dec06 08:03:57 ,82bn4512, bytes 7783
base3,Thu 21Dec06 08:01:03 ,06bn5600, bytes 77383
Output Would be:
6085 - 2
5600 - 2
6042 - 1
4270 - 1
4512 - 1
.....
And if it did not find any #### - 0
What would be the best and most efficient way to do this, the file I will be parsing is rather large.
Thanks,
Ad.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.