You can probably adapt either of these to your purposes.$_ = "some string with multiple words"; @first_three = (split)[0..2]; # or ($first_three) = /^\s*(\S+\s+\S+\s+\S+)/;
In reply to Re: How do I return the first n words of a string?
by Fastolfe
in thread How do I return the first n words of a string?
by d_brown3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |