pass in a parameter to indicate which word you want. (you can eaily turn this into a function). This does not create an array and saves space, assuming the only thing you care is the nth.$_ = "ele1 ele2 ele3 ele4 ele5 ele6"; m/(\w+\s*){$ARGV[0]}/; print $1;
In reply to Re: Capturing the nth word in a string
by pg
in thread Capturing the nth word in a string
by Roger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |