|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Comment on |
| ( #3333=superdoc: print w/ replies, xml ) | Need Help?? |
|
The answers above are all important to your effort to learn Perl. Pay close attention to that advice. But if I understand your latest node correctly, there's another aspect you need to learn about: regular expressions.
This is not the spot for a full regex tutorial but it appears to me that you need to use a capture to do what you want:
The parentheses tell the regular expression engine to capture their content (if that content exists in the line (of 3, comma-separated names, in this case) to the special variable, $1. Just a side note: I've written the code this way to stay close to your original... and to make the illustration fairly clear. But good practice calls for an intermediate step; assigning $1 to a named variable that won't be transient nor have the properties (esp. durability) of $1 that make it retain a prior match, if a new attempt fails. In reply to Re: Can't get the desired output..
by ww
|
|