URLEncode And URLDecode For Perl
PHP has builtin functions for urlencode and urldecode functions but for perl I’ve found the following from HERE that does the same thing:
sub URLDecode {
my $theURL = $_[0];
$theURL =~ tr/+/ /;
$theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
$theURL =~ s/<!–(.|\n)*–>//g;
return $theURL;
}
sub URLEncode {
my $theURL = $_[0];
$theURL =~ s/([\W])/”%” . uc(sprintf(”%2.2x”,ord($1)))/eg;
return $theURL;
}
on February 21st, 2006 at 4:45 pm
Post anything!
on March 6th, 2006 at 3:00 pm
finally a new template. its a lot cooler.