my $str = "4141414243"; $str =~ s/([a-fA-F0-9]{2})/chr(hex($1))/eg;