Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a 4 digit hexadecimal value in Perl?

Tags:

perl

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?

like image 794
shashi Avatar asked Oct 28 '25 23:10

shashi


1 Answers

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

like image 98
Günther Bayler Avatar answered Nov 02 '25 13:11

Günther Bayler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!