in reply to Re: unpack'ing "64-bit quantities"
in thread unpack'ing "64-bit quantities"

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.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^3: unpack'ing "64-bit quantities"
by isync (Hermit) on Jun 24, 2010 at 12:32 UTC
    Works! Would've never figured that one out myself... Thanks a bunch!