This shows you the differences between two versions of the page.
kurs:logfile_statistik [2014/09/10 21:22] |
kurs:logfile_statistik [2014/09/10 21:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | 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"; | ||
+ | } | ||
+ | |||
+ | </code> |