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

I have a file that contains all hex data. I need to convert this file so that it contains all decmial data. thanx
  • Comment on How do I convert a file with all hex to a file with all decimal values

Replies are listed 'Best First'.
•Re: How do I convert a file with all hex to a file with all decimal values
by merlyn (Sage) on May 21, 2002 at 16:39 UTC
    No matter how many times you post this (at least three or four so far), it still won't make any more sense to most of us.

    Please give an example of the input and desired output. "Hex" and "Decimal" are far too broad to narrow down any possible algorithm.

    -- Randal L. Schwartz, Perl hacker

      Sorry for the confusion. an example of the hex file would be
      40 30 4A 53 5B
      and an example of the decimal file would be
      64 48 74 83 91

      of course if you tried to open the hex file with notepad you would have jibberish, that is why I would like the conversion to dec. I know this can be done in PHP by using hexdec() and reading the whole file but I don't know how to do it in perl
      thank you
      and sorry for the confusion
Re: How do I convert a file with all hex to a file with all decimal values
by thor (Priest) on May 22, 2002 at 00:38 UTC
    erm...if you open the file in notepad and it's garbage, my guess is it's a binary file. Either way, play around with unpack to extract what you want.