Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # File: $Id: log_report.pl,v 1.3 2006/11/12 22:13:05 gxr3286 Exp gxr3286 $
- # Author: Govind Ramabadran
- # Description: This prints out the log report analysis of a log file
- # Revisions: $Log: log_report.pl,v $
- # Revisions: Revision 1.3 2006/11/12 22:13:05 gxr3286
- # Revisions: Implement Pt. 2
- # Revisions:
- # Revisions: Revision 1.2 2006/11/11 05:07:04 gxr3286
- # Revisions: Fixed it to print as per the sample output
- # Revisions:
- # Revisions: Revision 1.1 2006/11/11 04:26:04 gxr3286
- # Revisions: Initial revision
- # Revisions:
- while (<>)
- {
- chomp;
- $numlines++;
- $numchars += length $_;
- if ($_ =~/^((?:\d{1,3}\.){3}\d{1,3}).*$/)
- {
- $theIP = $1;
- ++$count{$theIP}
- }
- }
- my @lines = (50);
- my ($w, $c);
- push (@lines, sprintf("%7d\t%s\n", $c, $w)) while (($w, $c) = each (%count));
- print "There are $numlines lines and $numchars characters\n";
- print "\n";
- print "IP addresses in order of frequencies of requests:\n";
- for ($i = 1; $i < 50; $i++)
- {
- print sort { $b cmp $a } @lines;
- }
Add Comment
Please, Sign In to add comment