# The above shrunk a bit. $str =~ s/%([0-9A-F][0-9A-F])/chr(hex($1))/ieg; # - or more cryptic $str =~ s/%([0-9A-F][0-9A-F])/sprintf("%1c",hex($1))/ieg;