Welcome to the Monastery, odysee7. I hope your stay here will be a productive and educational one.

First of all, to your question....

Regarding your actual question itself, it is a little difficult without at least an example of what you are looking for, data-wise. If the exception messages are one-per-line, then this reduces down to something on the order of

# $logfilename being defined previously.... my (%errors); open(LOGFILE, $logfilename) or die(qq{Can't open $logfilename for in +put: $!\n}); while (my $line = <LOGFILE>) { # example format: mon day time server program[pid]: message my @lineparts = split(/\s+/, $line, 6); if ($lineparts[5] =~ m/^Error:/) { $errors{$lineparts[5]}{count}++; push(@{$errors{$lineparts[5]}{linenumber}}, $.); } } close(LOGFILE);
You could then display the results (as text) with something similar to:
print qq{ERROR REPORT\n\n}, qq{Error message\tOccurrances\n\tLines found on\n\n}; foreach my $k (sort keys %errors) { print $k, qq{\t}, $errors{$k}{count}, qq{\n}, qq{\t}, join(q{,}, @{$errors{$k}{linenumber}}), qq{\n}; }
This would give you something that looked like:
ERROR REPORT Error message Occurrances Lines found on Error msg 1 1 13 Error msg 8675309 5 3,7,21,55,82
At that point, adding HTML formatting to the report is reasonably-easily accomplished (either directly, or via a templating system, such as HTML::Template or Template::Toolkit, and is left as an exercise to the reader). If, however, the error message can cross lines, then you potentially have to keep track of multiple lines to ensure whether or not this is part of an error msg or not, which potentially leads to a much more involved processing loop initially.

Now, about your question....

You mention that you have a limited knowledge of perl, but sound like you have a need or desire to learn perl. That being the case, I feel you have come to the right place. The Monastery has a great deal of resources to offer to one wanting to learn (or learn more) about perl. The Tutorials section is an excellent place to start, and one that I highly recommend, containing information both on modules and techniques in perl, as well as information on the resources and general expectations in the Monastery (at the very least, the posts under the Welcome to the Monastery section may prove helpful in learning your way around here). Beyond the Tutorials section, there is the Categorized Q&A section, where a number of commonly-encountered questions are answered, the SoWP section where most questions are asked, and the Super Search, where you can try to determine if something you are wondering about has been asked about before. There is also the Chatterbox (or CB as it is known), where discussions occur most any time of the day, and (brief) questions can be asked,

I would caution you on thing or two, however.

  1. First of all, as the improvement of the body monktorate is a major goal here, asking for help in a way that would not further that goal (such as having the response sent back to you via email) is a bit frowned upon. jeffa points out an alternate method for being notified in his tutorial. It's not that uncommon an occurrance, but something to be aware of.
  2. Number two, the number of monks present at any time, and with a particular experience or skill set, varies by hour of the day and day of the week/month/year, so if you do not get a response immediately, don't fret too much about it.
  3. Lastly, the experience range herein is enormous, as is the range of personalities and styles. If you receive a terse or somewhat "cutting" response from someone, try to learn from it, but don't take it too personally. Most of the monks herein behave as professionals, and I cannot recall a time when I have personally observed a response (except perhaps from someone new at the time) that was an intentional personal attack.

Again, welcome, and I hope your stay with be a productive, educational, and enjoyable one.


In reply to Re: Parse Log Files by atcroft
in thread Parse Log Files by odysee7

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.