I have a text file (Microsoft Access Locked database (.LDB) file that I am able to read and display as a single stream using the short script as follows:
-----------------------------------------------------------
#!/usr/local/bin/perl/
open(INFILE,'TEST.LDB') || die("Could not open file!");
open(OUTFILE,"+>outfile");
while ($len=sysread(INFILE,$buf,2048))
{
print $buf,"\n";
}
close(INFILE);
close(OUTFILE);
-----------------------------------------------------------
the .LDB file contains records in the form of "Field:Element", and the first four fields are headers that are to be deleted or separated from the rest of the file. The variable $buf above contains a single stream of these "Field:Element" combinations.
How can I format and parse this file out in a form like:
Hdr1: Data
Hdr2: Data
Hdr3: Data
Hdr4: Data
Field1: Data
Field2: Data
Field3: Data
Field4: Data
Field5: Data
Field1: Data
Field2: Data
Field3: Data
Field4: Data
Field5: Data
etc. (Basically, how can I convert this single output stream into something in a readable format)
Thanks for your help.
-----------------------------------------------------------
#!/usr/local/bin/perl/
open(INFILE,'TEST.LDB') || die("Could not open file!");
open(OUTFILE,"+>outfile");
while ($len=sysread(INFILE,$buf,2048))
{
print $buf,"\n";
}
close(INFILE);
close(OUTFILE);
-----------------------------------------------------------
the .LDB file contains records in the form of "Field:Element", and the first four fields are headers that are to be deleted or separated from the rest of the file. The variable $buf above contains a single stream of these "Field:Element" combinations.
How can I format and parse this file out in a form like:
Hdr1: Data
Hdr2: Data
Hdr3: Data
Hdr4: Data
Field1: Data
Field2: Data
Field3: Data
Field4: Data
Field5: Data
Field1: Data
Field2: Data
Field3: Data
Field4: Data
Field5: Data
etc. (Basically, how can I convert this single output stream into something in a readable format)
Thanks for your help.