Christopher M Burger wrote:
> I was wondering if anyone had any ideas on how to parse a datafile
> with fixed length records but no carriage returns. All records are
> on one line.
The read() function lets you read a fixed block of bytes.
> There are 3 fields per record the first is 10 spaces,
> the second is 15 and the third is 40 then it starts back with 10
> again.
unpack() is good for this.
perldoc -f read
perldoc -f unpack
Here's an example. Record length is 65 (10+15+40):
open F, "<myfile.dat" or die $!;
my $buf;
while(read(F, $buf, 65)) {
my ($f1, $f2, $f3) = unpack 'a10 a15 a40', $_;
}
close F;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]