Hello, I have an array that I have dumped a file into. The file contains several hundred different sentences.
The array contains, for example:
User logged in successfully at 10:35:33
User logged in successfully at 10:35:34
User logged in successfully at 10:35:35
Error: Login failure!
User logged in successfully at 10:35:37
Error: Login failure!
Error: System failure at 01:23:22
Error: System failure at 01:23:40
User logged in successfully at 10:35:39
Error: System failure at 01:23:41
So... what I've been trying to do is create a perl script to tell me how many times each error occurred.
I would need the output to look like:
User logged in successfully at 10:35:33
The above event occurred 4 additional times
Error: Login failure!
The above event occurred 1 additional times
Error: System failure at 01:23:22
The above event occurred 2 additional times
I have been trying to figure out a way to make the script count each event individually, but the for loops I have been using are only counting the first few matches.
Can someone come up with an algorithm that can count these and output the results like I have listed? Thanks for any help you can provide!
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.