my $char = 'm'; my $octal = sprintf("%03o", ord($char)); my $hex = sprintf("%02X", ord($char)); print "Oktal: $octal\tHex: $hex\n";