in reply to Tidier and more efficient parsing code
It's kinda verbose, but I couldn't figure out how to get rid
of the first element during split.
{ undef $/; @temp = split /;/, <DATA>; # slurp file shift @temp; # Get rid of everything before first semicolon %sections = map { my($sect, @param) = split /[\n\r\f]+/;($sect, \@ +param) } @temp; } # Just to test it foreach (keys %sections) { print "$_ => [@{$sections{$_}}]\n"; } __DATA__ ;section1 foo bar ;section2 bar baz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Tidier and more efficient parsing code
by particle (Vicar) on Jan 26, 2002 at 00:10 UTC |