A co-worker is learning Perl through self study. He's borrowed my Llama book for a start. As part of the learning I've agreed to provide him with "real world" exercises.
Do the following exercises for analysing *nix log files seem reasonable to you? He seems to be having trouble with them. He does know about split and join and the basics of array and hash use. A few hundred lines of messages was snipped and dropped into the directory he's using for the exercises.
Problem #1: Read the log file messages. Print a list of: Count TimeStamp I'm looking for the number of log messages per hour of the day. S +omething like
144 Apr 10 04:00 280 Apr 10 05:00 Problem #2 Read the log file messages instead of counting the number of messag +es per hour, count the number of instances for each message. Something like 2 syslogd 1.4.1: restart (remote reception). 189 ntpd[3216]: synchronized to 192.168.1.15, stratum 3 1880 last message repeated 9 times Problem #3 Modify solution to problem #2 so that "last message repeated X time +s" adds to the count of the last message Problem #4 Modify solution to problem #3 to ignore the PID Meaning: ntpd[3216]: synchronized to 192.168.1.15, stratum 3 will report as ntpd: synchronized to 192.168.1.15, stratum 3 Problem #5 Modify solution to problem #4 to report on activity per hour Apr 10 04:00 - XXXXX xxxx ntpd: synchronized to 192.168.1.15, stratum 3 xxxx syslogd 1.4.1: restart (remote reception). replacing xxxx with the acutal numbers
In reply to Log parsing exercises for Perl beginner - reasonable? by mikeraz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |