in reply to unpack'ing "64-bit quantities"

Next problem: I am on 32bit and unable to find the substitute for unpack 'Q'...
# my @binTimes = map{ unpack 'Q', pack 'H16', $_ } @hexTimes; my @binTimes = map{ Math::Int64::uint64_to_number(pack 'H16', $_) } @h +exTimes; # wrong!
Related posts: Ubuntu bug report, another Perlmonks thread

Replies are listed 'Best First'.
Re^2: unpack'ing "64-bit quantities"
by BrowserUk (Patriarch) on Jun 23, 2010 at 11:27 UTC

    Doing this with a 32-bit only Perl is a tad more complex, but works. You break the 64-bit number into 2 32-bit values and then multiply them out. You do have to pay attention to endianess though.

    #! perl -slw use strict; use constant { MSEpoch_2_UnixEpoch => 116444736000000000, }; my $in = '0x50c2b17c7c04c9014c69ac817f04c90176b7ed3581f7ca01ee1183dede +a3c901'; my @hexTimes = unpack 'xx(A16)4', $in; my @binTimes = map{ my( $lo, $hi ) = unpack 'VV', pack 'H8H8', unpack 'A8A8', $_; $hi * 2**32 + $lo } @hexTimes; my @unixTimes = map{ ( $_ - MSEpoch_2_UnixEpoch ) /1e7 } @binTimes; print scalar localtime( $_ ) for @unixTimes; __END__ [13:52:05.69]C:\test>845551.pl Fri Aug 22 17:28:27 2008 Fri Aug 22 17:50:03 2008 Wed May 19 18:29:26 2010 Fri Mar 13 13:23:16 2009

    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.
      Works! Would've never figured that one out myself... Thanks a bunch!