bigsid has asked for the wisdom of the Perl Monks concerning the following question:

I have a hex file that I need to convert to a dec file.
  • Comment on How do I convert a hex file to a dec file

Replies are listed 'Best First'.
(jeffa) Re: How do I convert a hex file to a dec file
by jeffa (Bishop) on May 21, 2002 at 01:32 UTC
    If the 'hex file' is a text file, try:
    use strict; open (FH, 'hex_file.txt') or die $!; while (<FH>) { s/([a-f0-9]{2})/hex($1)/egi; print; }
    However, this works for 8 bit hex numbers (00-FF). If your 'hex file' uses 16 bit numbers (0000-FFFF), then replace {2} with {4}. Likewise use {8} for 32 bit numbers.