in reply to Best way to read and process a text file with multiline records
my $record_line=0; my @records; my $index=0; while(<$DATA>){ if ($record_line != 2){ if(/^Data_Raw/){ $records[$index]->{Data_Line}=$.; $record_line=2; }elsif(/^Data_group/){ $record_line=1; my($title,@value)=split; $records[$index]->{Data_Group}=join(,' ',@value)); } }elsif(/^Data_Value/){ $index++; my($title,@value)=split; $records[$index]->{Data_value}=join(,' ',@value)); $record_line=0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to read and process a text file with multiline records
by tsk1979 (Scribe) on May 22, 2009 at 08:31 UTC |