Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: match last element instead of first??

by naikonta (Curate)
on Oct 18, 2007 at 06:49 UTC ( #645654=note: print w/ replies, xml ) Need Help??


in reply to match last element instead of first??

Just as you ask, split the line. (assuming the separator is fixed).
$ perl -le '$line = shift; @fish = split /\s*fish\s*/, $line; print fo +r @fish' 'One fish two fish red fish blue fish' One two red blue
You may compare between regex and split solutions, if you like.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


Comment on Re: match last element instead of first??
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-07-08 03:41 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 (94 votes), past polls