my $str = 'https:\x2F\x2Fwww.google.com\x2Faccounts\x2FCheckCookie?chtml=LoginDoneHtml'; $str =~ s{\\x([0-9a-fA-F]{2})}{chr hex $1}eg; print $str;