Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Unpack for VMS binary files

by pfaut (Priest)
on Feb 19, 2003 at 22:44 UTC ( [id://236863]=note: print w/replies, xml ) Need Help??


in reply to Re: Unpack for VMS binary files
in thread Unpack for VMS binary files

The first value should be the low part and the second value the high part.

--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Replies are listed 'Best First'.
Re: Re: Re: Unpack for VMS binary files
by maderman (Beadle) on Feb 20, 2003 at 00:38 UTC
    I've imported your subroutine into my code... However, I'm not getting the what I think I should. If I've got it right, your routine should return the unix time in epoch seconds. However, doing a "gdate '+%s'" on my system shows the epoch seconds = 1045700265... a bit different to what the routine returns (see below). In my case, perhaps the unpack format of the low_long and high_long paramenters in the routine require a little alteration? BTW, reversing the order of $high and $low into &quad_to_epoch didn't help...
    print "$low $high ", &quad_to_epoch("$low $high"), "\n";
    low high &quad_to_epoch 2038398976 10599419 408804118300 2238398976 10599419 408804118300 2438398976 10599419 408804118300 2638398976 10599419 408804118300 2838398976 10599419 408804118300 3038398976 10599419 408804118300 3238398976 10599419 408804118300 3438398976 10599419 408804118300 3638398976 10599419 408804118300
    Regards, Stacy.
      You're calling the routine very wrong there--if nothing else there's a space in the middle of the series of bytes, which'll screw things up a lot, and unless the two variables actually have the exact 4 bytes of the data from the disk file for their fields (not the string value of the 4-byte integer converted to a real int, mind, but the actual 4 bytes from disk) the conversion will go horribly wrong.

      I've appended a version that you might find more useful.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://236863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found