maderman has asked for the wisdom of the Perl Monks concerning the following question:
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.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) "
#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unpack for VMS binary files
by tachyon (Chancellor) on Feb 19, 2003 at 02:38 UTC | |
|
Re: Unpack for VMS binary files
by pfaut (Priest) on Feb 19, 2003 at 02:41 UTC | |
by maderman (Beadle) on Feb 19, 2003 at 02:55 UTC | |
by pfaut (Priest) on Feb 19, 2003 at 02:58 UTC | |
by maderman (Beadle) on Feb 19, 2003 at 04:36 UTC | |
by Elian (Parson) on Feb 19, 2003 at 17:31 UTC | |
| |
|
Re: Unpack for VMS binary files
by jasonk (Parson) on Feb 19, 2003 at 02:31 UTC |