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

I have the following hex string: '00000000000001ad013fffffff3fffffff'. I use the following unpack: 'NNCNd' which gives me '0 429 1 1073741823'. What I was expecting was '0 429 1 1073741823 1073741823' How should I tweak my unpack command?

Replies are listed 'Best First'.
Re: unpacking &* packing
by JavaFan (Canon) on Jul 13, 2009 at 12:37 UTC
    Did you try "NNCNN"?
      WOW! ..that was too easy! ..thanks!!
Re: unpacking &* packing
by BrowserUk (Patriarch) on Jul 13, 2009 at 14:45 UTC

    Assuming a 32-bit Perl (and the prevalent expectation of char == byte), NNCNd would require 1*1(C) + 3*4(N) + 1*8(d)== 21 bytes of data, and you only have 17.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.