Think about Loose Coupling | |
PerlMonks |
Pattern match for split() - need match but not match syntaxby Tanoti (Initiate) |
on May 06, 2008 at 14:02 UTC ( [id://684949]=perlquestion: print w/replies, xml ) | Need Help?? |
Tanoti has asked for the wisdom of the Perl Monks concerning the following question:
I have some text from a third-party app which I'm storing in a single variable that needs parsing. I am using:
split /\n/, $app_text;
to break it into lines for processing. I'm looking for "Field:Value" lines and ignoring everything else. For most of the text this is fine, however the external app is borking some of the fields and putting a \n after the colon meaning the Value for that field ends up in the next array element. Here's some sample code:
Produces:
How can I tell split to split on the \n but not if preceeded by a colon, so I get two:turtle doves for the second array element in the above example? Many thanks, John
Back to
Seekers of Perl Wisdom
|
|