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
You could then display the results (as text) with something similar to:# $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);
This would give you something that looked like: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}; }
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.ERROR REPORT Error message Occurrances Lines found on Error msg 1 1 13 Error msg 8675309 5 3,7,21,55,82
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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |