Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Answer: How do I return the first n words of a string?

by Zombie Wyzelli (Initiate)
on Apr 16, 2002 at 13:27 UTC ( #159473=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I return the first n words of a string? - Answer contributed by Zombie Wyzelli

Golf swings on...
$str = 'yo ho ho and a bottle crumbs. hangin and bangin in the upper-class slums.'; print join ' ', (split /\s+/, $str)[0..4];

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-01-17 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (194 votes). Check out past polls.

    Notices?