![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Double-duty commasby Sprad (Hermit) |
on Feb 25, 2005 at 17:15 UTC ( [id://434576]=perlquestion: print w/replies, xml ) | Need Help?? |
Sprad has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to parse a string where the comma is pulling double duty. Here's an example:
foo:a,bar:a,b,c,baz:d This should result in the following array, which I can then process further as needed:
I could do this with a two-pass method, where first I do a substitution like this: s/,(\w+):/MONKEYBUTT$1:/g; and then split on /MONKEYBUTT/ (or some other unlikely string). But is there a more elegant solution that wouldn't offend our simian friends?
---
Back to
Seekers of Perl Wisdom
|
|