How to print a 4 digit hexadecimal value in Perl?

Viewed 117
my $hex = sprintf('%X', oct("0b$reverse_str"));
print FOUT "HEX FORMAT: $hex\n";

If the hexa value is 007E, it is printing only 7E. How to get a 4 bit hexa value printed in Perl?

1 Answers

You have to use %04X instead of %X.

Related