HTTP::Browscap - Get web browser information by specific browscap.ini file
use HTTP::Browscap;
my $agent='Mozilla/4.8 [en] (X11; U; Linux 2.4.19 i686; Nav)';
my $browscap = new HTTP::Browscap('/path/to/browscap.ini'); $browscap || die("Browscap did not initialize: $!"); if(length($browscap->{'errors'})) { print "Browscap file errors:\n". join("\n ", @{$browscap->{'errors'}})."\n"; }
my $browser = $browscap->identify($agent); $browser || die("Error getting browser info: $!"); print "Browser ".$browser->{'browser'}. " version ".$browser->{'version'}. " on platform ".$browser->{'platform'}."\n";
$browscap->parse('/path/to/another/browscap.ini') || die("Browscap did not initialize: $!");
my $platform=$browscap->identify_variable($agent, 'platform'); $platform || die("Cannot get browser platform: $!"); print "Browser platform: $platform\n";
$browscap->free();
The HTTP::Browscap object tries to get as much information about web browser comparing its User-Agent identification to a special database in browscap.ini file. If calling a Perl script via CGI, the browser identification string can be found in environmental variable $ENV{'HTTP_USER_AGENT'}.
Per browser can be set these variables: browser, version, minorver, majorver, platform, authenticodeupdate, css, frames, iframes, tables, cookies, backgroundsounds, vbscripts, javascript, javaapplets, javaappletsframes, activexcontrols, height, width, ak, sk, cdf, aol, beta, win16, netclr and special variable parent.
You can find various browscap databases on the internet free for download, for example on http://www.garykeith.com/browsers/downloads.asp or http://www.cyscape.com/browscap/
You can of course try to find your own favourite on http://www.google.com/ ;-)
Another Perl module HTTP::BrowserDetect.
http://kyberdig.cz/projects/browscap/
C. McCohy <mccohy@kyberdigi.cz> Feel free to report bugs, suggestions or comments.
Copyright 2003 C. McCohy. This program is free soft, distribute it and/or modify it under the terms as Perl itself.