Detect WAP browser and redirect to different url in Perl

Do you want to have the same url for your Web and Wap broswer? The following is the code to do so in Perl:


#!/usr/local/bin/perl
use CGI;

my $query = new CGI;

my @list=$query->Accept();

my $htmlsite="http://www.artofmobile.com/index.html";
my $wmlsite="http://www.artofmobile.com/index.wml";

my $wml=0;
my $html=0;

foreach (@list) {
   $html=1 if /text\\/html/i;
   $wml=1 if  /wap/;
}


print $query->redirect($wmlsite)  if $wml==1;
print $query->redirect($htmlsite) if $html==1;
print $query->redirect($wmlsite);