![]() |
|
No such thing as a small change | |
PerlMonks |
Re: how to splitby reasonablekeith (Deacon) |
on Dec 18, 2007 at 09:54 UTC ( #657632=note: print w/replies, xml ) | Need Help?? |
If you can guarantee that the greater-than sign won't appear in your data, then you might as well use that as your end-of-line marker (your example shows confused usage of this, so you might want to look up the 'slurp' idiom). Each read from the file gets one set of results (the first read is blank, because we've set '>' as an end of line marker, but we're checking our data so it's okay). This can then be split to header/line data and pushed to the array.
Note that the whole thing is in curly brackets so that our value for $/ gets restored for any subsequent code (really, look up the slurp idiom.)
--- my name's not Keith, and I'm not reasonable.
In Section
Seekers of Perl Wisdom
|
|