Suppose you have some web access logs:
annoy.com - - [12/Apr/2004:14:33:56 -0400] "GET /perl-qa/2003-03 HTTP/1.0" 301 241 "-" "Mozilla/5.0" annoy.com - - [12/Apr/2004:14:36:25 -0400] "GET /perl-qa/2003-03/ HTTP/1.0" 200 7394 "-" "Mozilla/5.0" 1.2.3.4 - - [12/Apr/2004:14:42:08 -0400] "GET /robots.txt HTTP/1.1" 404 216 "-" "Some browser" 1.2.3.4 - - [12/Apr/2004:14:42:11 -0400] "GET /cgi-bin/namazu.cgi?idxname=perl6-internals HTTP/1.1" 200 9709 "-" "Some browser" |
You want to find out how many times you got hit from annoy.com.
#!/usr/local/bin/perl use strict; use AnyData; my $table = adTie( 'Weblog', 'access_log', 'u' ); my $hits = $table->{{remotehost => 'annoy.com'}}; print "I got ", scalar @$hits, " hits."; |