User Tools

Site Tools


kurs:logfile_statistik
open (FH , $ARGV[0]);

while ($l = <FH>) {
# 195.251.218.35 - - [18/Oct/2006:07:31:05 +0200] "POST /wp-comments-post.php HTTP/1.1" 302 -
  $l =~ /^(.*?)\s/;
  $ip = $1;
  $ip =~ /(.*)\./;
#  print "$1\n";
  $ipstat{$1} = $ipstat{$1} + 1 ;
}

# hash per value sortieren
@keys = sort {
  $ipstat{$a} <=> $ipstat{$b}
  } keys %ipstat;       # and by value

foreach $key ( @keys) {
   print "$key $ipstat{$key} \n";
}
kurs/logfile_statistik.txt · Last modified: 2014/09/10 21:22 (external edit)