Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by princepawn (Parson)
on Oct 26, 2000 at 20:23 UTC ( #38661=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 princepawn

Time for some Perl Golf:
$str= 'yo ho ho and a bottle crumbs. hangin and bangin in the upper-class slums.'; @word = ($str =~ /(\w+)/g); print join ':', @word[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 scrutinizing the Monastery: (5)
As of 2016-12-03 22:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (60 votes). Check out past polls.