Hi all, I have some VMS binary files with the following descrition:
SysTim int(8) deci-microseconds since midnight on 17-Nov-1858 +AEST Record_No int(2) = # of 20-secs since midnight + 1 WndSpdMax int(2) km/h WndSpdAvg int(2) km/h WindDir int(2) degrees [0..540] AirPress int(2) millibars (hectopascals) RainBuckets int(2) tips in the preceeding 20 seconds - 1 tip = 0.2m +m RelHumid int(2) % OutTemp int(2) degrees-celsius InTemp int(2) " MaserTemp int(2) " CbnTemp int(2) " ExtrTemp int(2) "
The system time value is the number of deci-microseconds since midnight on 17-Nov-1858 (local time) - the local time equivalent of the origin of Modified Julian Date (gosh). The temperature values are quoted in tenths of a degree. The record length is 8 (32-bit words) and that there are 4320 (= 3 x 60 x 24) records in each file, i.e. one for every 20 seconds in a day. There is no padding. There are no end-of-record markers. With the following code, I have attempted to decode from binary to ascii, but with no success. Any ideas? Thanks in advance, Stacy.
#!/usr/local/gnu/bin/perl $template="i8 i2 i2 i2 i2 i2 i2 i2 i2 i2 i2 i2 i2"; $recordsize=length(pack($template, ( ))); open(FILE,"$ARGV[0]") or die "unable to open file: $!"; while(read(FILE,$record,$recordsize)) { @fields = unpack($template,$record); print $fields[0], "\n"; } close(FILE); exit 0;

In reply to Unpack for VMS binary files by maderman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.