- NAME
- SYNOPSYS
- DESCRIPTION
- PACKAGE METHODS
- PACKAGE VARIABLES
- BROWSER SPECIFIC VARIABLES
- GETTING BROWSCAP.INI
- SEE ALSO
- HOMEPAGE
- AUTHOR
- COPYRIGHT
NAME
HTTP::Browscap - Get web browser information by specific browscap.ini file
SYNOPSYS
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();
DESCRIPTION
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'}.
PACKAGE METHODS
-
new HTTP::Browscap ($browscap_file)
- The constructor parses the given file and creates its own browser tree. Any errors occuring while parsing the file are stored in special array variable. In case of errors (i.e. nonexistent file) returns undef and error message can be found in ``$!'' variable. parse ($browscap_file)
- This method cleans stored browser tree, parses given file and creates new browser tree. Variable holding parsing errors is cleaned too and created again, if any errors occure. In case of errors (i.e. nonexistent file) returns undef and error message can be found in ``$!'' variable. identify ($user_agent_identifictaion)
- Returns a hash reference with known information about browser. Returns undef in case of errors (i.e. browser not found in database) and error message can be found in ``$!'' variable. identify_variable ($user_agent_identification, $variable)
- Returns string with the corresponding value of variable to specified browser. Returns undef in case of errors (i.e. browser not found in database or unknown variable or not set value) and error message can be found in ``$!'' variable. free ()
- Cleans browser tree and error messages. Use this to free memory, browscap files usually have more than 100 kB.
PACKAGE VARIABLES
-
@errors
- An array containing errors while parsing the browscap file. %HTTP::Browscap::variables
- Anonymous hash containing variables which can be set to every browser (plus special 'parent' variable). Variable names are keys of this hash, variable description are values of this hash.
BROWSER SPECIFIC VARIABLES
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.
GETTING BROWSCAP.INI
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/ ;-)
SEE ALSO
Another Perl module HTTP::BrowserDetect.
HOMEPAGE
http://kyberdig.cz/projects/browscap/
AUTHOR
C. McCohy <mccohy@kyberdigi.cz> Feel free to report bugs, suggestions or comments.
COPYRIGHT
Copyright 2003 C. McCohy. This program is free soft, distribute it and/or modify it under the terms as Perl itself.