[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Parsing?



Hello all,
        I am writting a Perl(CGI) script that will automatically detect and
route users according to the type of browser they are using, so that they
will either get the enhanced page or the non-Netscape page.

I am having trouble parsing the HTTP_USER_AGENT information.

I have this:

# Define Variables
$browser = $ENV{'HTTP_USER_AGENT'};

#parse $browser
$browser =~ s/\s.*//;
($software, $version) = split (/\//, $browser, 2);
($number ,$suffix) =~ split (/([^\d.].*)/, $version);


what it is supposed to do is parse:

Mozilla/2.0b5 (Macintosh, ...)

to this

$software =Mozilla
$version = 2.0b5

everything else is neglected.

with $version it is parsed down to just "2"

$number = 2

This way 2.0 users go to a certain page and 1.12 users another and so on
with Non-netscape.

This is the If statement:

if ($software eq 'Mozilla')
{
    if ($number >= 2)
        {
        For 2.0 users,   Blahh, Blahh, Blahh
        Meta tag to send users to http://what.ever.com
        }
        else {
        For 1.12 users,   Blahh, Blahh, Blahh
        Meta tag to send users to http://what.ever.com
        }
}
else {
For Non-Netscape users,   Blahh, Blahh, Blahh
}

end;

The problem is that I do not get 2, even though I am using a 2.0b5 version.
The script just sends me to 1.12.

If any of you Perl experts can help out I would appreciate it.

TIA,


Thanks,
        Thai Nguyen
______________________________
|MDIS Pro-IV
|<<http://www.ca.mdis.com>>
|
|tng@mdcsc.ca.mdis.com
|trpplj@quick.net