Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Split at specific spaces

by rubasov (Friar)
on May 11, 2010 at 08:15 UTC ( #839394=note: print w/ replies, xml ) Need Help??


in reply to Split at specific spaces

Another way returning the split parts only:

perl -E 'say for split /\S+\s+\S+\s+\S+\K\s+/, "1 2 3 4 5 6 7 8 9"'
Or written shorter:
perl -E 'say for split /(?:\S+\K\s+){3}/, "1 2 3 4 5 6 7 8 9"'


Comment on Re: Split at specific spaces
Select or Download Code
Re^2: Split at specific spaces
by BrowserUk (Pope) on May 11, 2010 at 08:36 UTC
    perl -E 'say for split /\S+\s+\S+\s+\S+\K\s+/, "1 2 3 4 5 6 7 8 9"'

    Neat!++ It never crossed my mind that /K would work with split.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Split at specific spaces
by RedElk (Hermit) on May 11, 2010 at 14:53 UTC

    As a newbie I'm reading and deciphering your response. My reference material doesn't seem to mention "K" anywhere. Can you (or anyone) enlighten me?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://839394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2015-07-04 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls