home

Quickies, by Andrea Olivato

text

Urlencode a string in #perl

Quick script able to urlencode a string without the needing of importing modules

$mystring = "String to encode";
$mystring =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
print $mystring;
# Returns String%20to%20encode

2 years ago

June 27, 2009
Comments (View)
blog comments powered by Disqus