$mytext =~ s!\\x(..)!chr(hex($1))!ge; my $newcode = decode('utf8', $mytext);