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];
Electric eels were invented at the same time as electricity
Before electricity was invented, electric eels had to stun with gas
Results (407 votes). Check out past polls.