![]() |
|
P is for Practical | |
PerlMonks |
Understanding regular expressions: why do I have to use map to clear up undefs in regex output?by corenth (Monk) |
on Jun 19, 2009 at 21:43 UTC ( #773137=perlquestion: print w/replies, xml ) | Need Help?? |
corenth has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to parse a simple string. In doing so, I want to get rid of quotes. The regex as it stands doesn't reflect the possibility of escaped quotes.
Let's take this string: '1,2,3,4,"fine","day","today",' If I could remove all the qoutes (or didn't care) I could use:to give me : I don't wan't those quotes, so I : which gives me: Oh NO!!! all those undefs and I might want to use a hash instead of an array!! Oh, what can I do? to get: LOVELY!! But why? Granted, this exercise has helped me to understand map() alot better, but I would like to know what it is about my pattern that creates all those undefs, and I would like to know how (if there's a way) I could do this without all those undefs. I'm happy with my solution, but I'm unhappy with the fact that I don't understand the problem. If you have an idea about how to help me understand, I'd be very thankful. ---
($state{tired})?(sleep($wink * 40)): (eat($food));
Back to
Seekers of Perl Wisdom
|
|