Urlencode.pl

From Organic Design wiki
# Encode string for use in an URL
$str =~ s/([^-_A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;</perl>