Argh :-(
Why does this always end up going through the loop and settling for the 'else' statement every time - even though all the others are true?
my $referrer = $ENV{HTTP_REFERER};
my $goto = $referrer;
if ($referrer =~ m|/en/|g) {
$goto =~ s|/en/|/ws/|g;
}
elsif ($referrer =~ m|/ws/|g) {
$goto =~ s|/ws/|/en/|g;
}
elsif ($referrer =~ m|lang=en|g) {
$goto =~ s|lang=en|lang=ws|g;
}
elsif ($referrer =~ m|lang=ws|g) {
$goto =~ s|lang=ws|lang=en|g;
}
else {
die("Can't understand what to translate to.");
}
print $query->redirect($goto);
}
I'm using this on URLs such as the following two, but it never matches for some bizarre reason. Can someone spot where I'm, going wrong?
http://www.geo-drws.co.uk/cgi-bin/odb.cgi?browse=places;res_places=1;res_places_sl=1;lang=en;
- wil
Why does this always end up going through the loop and settling for the 'else' statement every time - even though all the others are true?
Code:
sub translate { my $referrer = $ENV{HTTP_REFERER};
my $goto = $referrer;
if ($referrer =~ m|/en/|g) {
$goto =~ s|/en/|/ws/|g;
}
elsif ($referrer =~ m|/ws/|g) {
$goto =~ s|/ws/|/en/|g;
}
elsif ($referrer =~ m|lang=en|g) {
$goto =~ s|lang=en|lang=ws|g;
}
elsif ($referrer =~ m|lang=ws|g) {
$goto =~ s|lang=ws|lang=en|g;
}
else {
die("Can't understand what to translate to.");
}
print $query->redirect($goto);
}
I'm using this on URLs such as the following two, but it never matches for some bizarre reason. Can someone spot where I'm, going wrong?
Code:
http://www.geo-drws.co.uk/html/en/places.html http://www.geo-drws.co.uk/cgi-bin/odb.cgi?browse=places;res_places=1;res_places_sl=1;lang=en;
- wil