laziness, impatience, and hubris | |
PerlMonks |
Re: Regxp: signaling when to stopby Trizor (Pilgrim) |
on Jun 20, 2007 at 15:14 UTC ( [id://622278]=note: print w/replies, xml ) | Need Help?? |
Simply use capturing groups like this: (You also want a non greedy operator as other posts have pointed out.)
After that your target name will be inside $1. If you want to place it all on one line, you can use =~ in list context and get the results as a list like this:
Just be sure that the list that you're assigning to has the same number of elements as there are capturing groups (the parts of the pattern inside parens) or else you'll run into trouble with values going to the wrong place. If you're paranoid about this you could assign to an array and shift it to get the first group, but that adds a lot of uneccessary overhead. Edit: Forgot a semi-colon.Edit 2: Made the assumption that all living beings have two word names.
In Section
Seekers of Perl Wisdom
|
|