Browser Detection in Perl

They have: 19 posts

Joined: Feb 2000

How can I find out if a browser is below versions 3.0 in Netscape and Explorer or any browser - I know the type gets passed in in $ENV{'HTTP_USER_AGENT'} but this doesn't offer a general way to extract the version number. Can anyone help?

They have: 1,587 posts

Joined: Mar 1999

hmm, that's the only way i know.

------------------
Thumbs up or down ratings of the best and worst ways to make $$$ on the net. CLICK 4 CASH! from Affiliate Programs and Ad Networks

Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?

They have: 850 posts

Joined: Jul 1999

Here is what $ENV{'HTTP_USER_AGENT'} generally looks like if the browser is IE, or Netscape:

IE: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)

Netscape: Mozilla/4.04 [en] (Win95; U)

Not sure if this is right, but you could try somthing like:

code:

if($ENV{'HTTP_USER_AGENT'} =~ m/compatible; MSIE (.+?);.*/sogi)
{
	$version = $1;  #browser was IE
}
if($ENV{'HTTP_USER_AGENT'} =~ m/Mozilla\/(.+?)\s.*/sogi)
{
	$version = "$1"; #browser was Netscape	
}
[/code]

This will get the version for Netscape and Explorer, and put it into $version.

------------------
Termites eat through wood two times faster when listening to rock music.

[This message has been edited by robp (edited 13 March 2000).] 

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.