in reply to Re^2: HEX to floating point
in thread HEX to floating point

First, you have a typo in your hex string: '00000034000031b110191403b8811bb1366e4' (the highlighted 1).  Second, if you run this on AIX (as I figure from the presence of "AIX" in the shebang path), you most likely don't want the reverse stuff anyway, as AIX typically runs on big-endian hardware, which already matches the binary format of your numbers...

In other words, on AIX, this should work (actually it does — tried it):

my $raw = pack "H*", '00000034000031b10191403b8811bb1366e4'; print "$_\n" for unpack 'NNCCd', $raw;

Replies are listed 'Best First'.
Re^4: HEX to floating point
by Spooky (Beadle) on Jun 16, 2008 at 18:12 UTC
    Thanks so much - it work's great! One other question: what would be the best way to assign each value to a variable name? Again, thanks for your help - I'm definitely sold on PERL even though I'm a novice.
      what would be the best way to assign each value to a variable name?

      Something like this, for example:

      my ($long1, $long2, $byte1, $byte2, $double) = unpack 'NNCCd', $raw;

      (of course, choose names as you see fit...)

      Your next lesson is to understand that it's Perl (the language) or perl (the interpreter) but never PERL.

      Yes, we are picky about such things:)


      Unless I state otherwise, all my code runs with strict and warnings
        Whatever you say - you're the Monk! ...any suggestions on good Perl books?