hello everybody,
i need some help in binary file handling in perl. can anybody give me some information about binary file. actully i am reading data from some text file and extracting some usefull information from there and want store in my own binary file with .vbf extension ( not like .dat file.) i am putting code here for reading text file and extract some information from there but how can i store that information in my own binary file.
i want to store that information in this format:
<2 byte type><4 byte count><4 byte address><1 to 64 byte data><2 byte checksum>
can anybody help me in this code. or give me some usefull link to solve this kind of problem.and how can i write rule for this kind of parsing.
Thanks & Regard
Lokiiiiiiii
i need some help in binary file handling in perl. can anybody give me some information about binary file. actully i am reading data from some text file and extracting some usefull information from there and want store in my own binary file with .vbf extension ( not like .dat file.) i am putting code here for reading text file and extract some information from there but how can i store that information in my own binary file.
Code:
use warnings;
use strict;
{
my @file_contents;
open (INPUT, "sample.s37");
{
@file_contents = <INPUT>;
}
close(INPUT);
my $i;
for($i=0;$i<@file_contents-1;$i++)
{
my $Type = substr ($file_contents[$i], 0,-41);
my $Count = substr ($file_contents[$i], 2,-38);
my $Address = substr ($file_contents[$i], 4,-35);
my $Data = substr ($file_contents[$i], 8,-3);
my $CSum = substr ($file_contents[$i], 40);
printf("\nType:$Type\nCount:$Count\nAddress:$Address\ndata :$Data\nCheckSum:$CSum");
}
}
<2 byte type><4 byte count><4 byte address><1 to 64 byte data><2 byte checksum>
can anybody help me in this code. or give me some usefull link to solve this kind of problem.and how can i write rule for this kind of parsing.
Thanks & Regard
Lokiiiiiiii
Comment