I imiagine there is more that one way, but assuming PER is a
record delimiter, you need to check if you have hit a delimiter
and then start grabbing data. I would wonder though if all
of your records look like this (ie, all on one line) why do you need
a delimiter?
Anyway, assuming you do need the delimiter:
/usr/bin/perl-Tw
use strict;
use Text::ParseWords;
open(DATA,"basicdez.dat") || die "Cannot open datfile: $!\n";
my @data;
my $i = 0;
my $new_record=0;
while (<DATA>)
{
chomp;
last if /^"EOS"$/;
if (/^PER\s*$/) {
$new_record=1;
}
elsif ($new_record) {
@data = "ewords('\s+', 0, $_);
print "Name = $data[0]\n";
print "Color = $data[1]\n";
print "Date = $data[2]\n";
$new_record = 0;
}
}