in reply to Best way to parse multiline data?
Read it line by line, but keep track of which section you're in and if the section hasn't change, just concatenate. Then, when the section changes, go ahead and process the last section, then set the current section to the new one.
my ($section, @value); while (<FILE>) { chomp; my ( $temp_section, $temp_value ) = /^(?:([^:]+):)?\s*(.*)/; if ( $temp_section ) { if ( $section ) { # Process the old value somehow. } $section = $temp_section; @value = ( $temp_value ); } else { push @value, $temp_value; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to parse multiline data?
by BrowserUk (Patriarch) on Apr 16, 2005 at 03:39 UTC | |
by dragonchild (Archbishop) on Apr 18, 2005 at 12:36 UTC | |
|
Re^2: Best way to parse multiline data?
by jalewis2 (Monk) on Apr 16, 2005 at 03:16 UTC |