#!/usr/bin/env perl do "common.pl"; %user_agent; open(FILE,$file); while() { /\S*\ \S*\ \S*\ \S*\ \S*\ (\S*)\ \S*\ \S*\ \S* \S*\ ".*"\ (.*)$/; $url = $1; $agent = $2; if ( not exists $user_agent{$agent} ) { $user_agent{$agent} = "UN"; } } close(FILE); $robot; foreach $agent (sort keys %user_agent) { if ( $agent =~ /(?:bot|spider|slurp|search|crawler|checker|downloader|worm)/i ) { $robot++; } # Manual search remaining agents # else { # print $agent; # } } $total = scalar(keys %user_agent); print "robot/others user-agent: $robot/$total ", percent($robot,$total), "\n"; exit(0);