use Encode; my $ucode = q/\xc3\xa4/; # note the use of 'q', not 'qq' my $newcode = decode('utf8',$ucode =~ s/\\x([a-fA-F0-9]{2})/chr hex($1)/egr);