Updatemy @user_agent_list= ({title=>'Internet Explorer', string=>'MSIE', url=>'http://www.microsoft.com/windows/ie/defa +ult.asp'}, {title=>'Konqueror', string=>'Konqueror', url=>'http://www.konqueror.org/'}, {title=>'Galeon', string=>'Galeon', url=>'http://galeon.sourceforge.net/'}, {title=>'Opera', string=>'Opera', url=>'http://www.opera.com/'}, {title=>'Dillo', string=>'Dillo', url=>'http://dillo.cipsga.org.br/'}, {title=>'Mozilla', string=>'Mozilla\/5', url=>'http://www.mozilla.org/'}, {title=>'Netscape', string=>'Mozilla\/4', url=>'http://wp.netscape.com/download/'}, ); print div({-id=>'browser'}, p("Browser: $ENV{'HTTP_USER_AGENT'}"),); for my $browser (@user_agent_list) { if (($ENV{'HTTP_USER_AGENT'}) =~ /$browser->{string}/) { print p("You seem to be using", a({-href=>"$browser->{url}"}, $browser->{title}, )); } }
..and that also matches what Netscape displays. Running this against those two browsers will print out two lines for each of them (IE matches Netscape and IE, and vice-versa for Netscape).Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
I'll try to find a way around this without having to use !~ matching.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Short and Sweet Browser Detection
by KM (Priest) on Jun 07, 2002 at 17:27 UTC | |
by jeffenstein (Hermit) on Jun 07, 2002 at 18:55 UTC | |
by KM (Priest) on Jun 07, 2002 at 19:09 UTC | |
by Dog and Pony (Priest) on Jun 07, 2002 at 19:16 UTC | |
by KM (Priest) on Jun 07, 2002 at 19:44 UTC | |
by KM (Priest) on Jun 07, 2002 at 19:21 UTC | |
|
Re: Short and Sweet Browser Detection
by chromosundrift (Novice) on Jun 16, 2002 at 11:56 UTC | |
by hacker (Priest) on Jun 17, 2002 at 10:55 UTC |