in reply to Translating the the useragent field of weblogs
Anything not detected by this just comes back as the original user-agent string.
sub munge_browser { $string = shift () || die "$!"; chomp($string); $string =~ s/^\s*//; ($first, $second, $third) = split ('\(|\)', $string); ($x, $version) = split ('/| ', $first); $version =~ s/[^\d.]//g; if ($first =~ /mozilla/i && $second !~ /compatible/i) { $browser = 'Netscape'; } if ($browser == 'Netscape' && $version =~ /5/) { $version = 6; } if ($second =~ /MSIE/i) { $browser = 'Explorer'; } if ($third =~ /opera ([\d.]+)/i) { $browser = 'Opera'; $version = $1; } if ($second =~ /icab ([\d.]+)/i) { $browser = 'iCab'; $version = $1; } if ($second =~ /MSIE\s([\d.]+)/i) { $version = $1; } if ($second =~ /win/i) { $system = 'PC'; } if ($second =~ /mac/i) { $system = 'Mac'; } if ($browser) { return "$browser $version ($system)"; } else { return "$string"; } }
($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
|
|---|