from: $data =~ s/%([\da-f][\da-f])/chr(hex($1))/eg; to: $data =~ s/%([\da-fA-F][\da-fA-F])/chr(hex($1))/eg;