Q&A > strings > How do I return the first n words of a string? - Answer contributed by princepawn
'yo ho ho and a bottle crumbs.
hangin and bangin in the upper-class slums.';
@word = ($str =~ /(\w+)/g);
print join ':', @word[0..4];
There is no Extraterrestrial life
There aren't any suitably capable Extraterrestrials
Interstellar travel is too difficult
We're too uncool / not worth the trouble
What do you mean they haven't visited?
Results (463 votes). Check out past polls.