in reply to Re: Reading Binary files in Perl
in thread Reading Binary files in Perl
Below is the structure or format of data in binary file:
<structure>
Offset Field Name size
0x0 magic_numbe 8
0x8 retry_count 1
0x9 number_record 1
0x10 dc_timestamp 8
<\structure>
and the code is:
open(FH, "<DCdata.bin") or die "Can't open DCdata.bin file for reading +!"; binmode(FH); while (<FH>) { $index = 0; foreach $field_name (keys (%disk_structure)) { $value = read (FH, $buffer, ($field_name * 8), 0); print tell (FH); print "\n"; } foreach $f_name (keys (%disk_structure_record)) { $value_record = read (FH, $buffer, ($f_name * 8), 0); #print tell (FH)\n; } } close(FILE);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Reading Binary files in Perl
by BrowserUk (Patriarch) on Aug 25, 2010 at 13:16 UTC | |
Re^3: Reading Binary files in Perl
by Corion (Patriarch) on Aug 25, 2010 at 12:59 UTC |
In Section
Seekers of Perl Wisdom