in reply to Best way to read and process a text file with multiline records

Not sure if this is what you're asking, but something like the following would create the data structure I think you're looking for fairly quickly. Warning: totaly untested, modify 'til it works ;),
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; } }
  • Comment on Re: Best way to read and process a text file with multiline records
  • Download Code

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
    This seems very quick! I will work upon this to create my hash!
    Since line continuation character is only in data_raw, and actual data is not important, just the line number is important, I do not need to bother with the "\" character!