P is for Practical | |
PerlMonks |
Re: Understanding alternationby g0n (Priest) |
on Feb 03, 2006 at 15:06 UTC ( [id://527673]=note: print w/replies, xml ) | Need Help?? |
'Does the match quit once it finds the first occurence of one of the alternatives?'Yes.
'Will that then try and match each alternative in the string and then return?'Sort of. It will keep looking through the string, even after it's found a match, until it doesn't find any more matches. It's a fine distinction, but it doesn't look through the string for the first, then look through again for the second etc, AFAIK. Note that in the context you are using it, it will just return true, not a list of matches.
'Can I do that using the alternation ..'Yes, like this:
($1 contains the value matched by the pattern, so you are replacing each match with itself, prepended by \n). --------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
In Section
Seekers of Perl Wisdom
|
|