Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: how to split a string and take certain position?

by mreece (Friar)
on Sep 24, 2007 at 04:26 UTC ( #640653=note: print w/replies, xml ) Need Help??


in reply to how to split a string and take certain position?

sure, if you group your parens appropriately -- (split)[$i]:

  print( (split(/:/, $sentence))[1] );  # negative indexes work too

or the less cluttered: print +(split /:/, $sentence)[1];

for the latter question, consider: ($match) = $sentence =~ /([^:]+)$/

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2023-03-24 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (61 votes). Check out past polls.

    Notices?