$string = "COM7:"; $string =~ s/(.)/sprintf("%02X",ord($1))/seg; print "$string\n";