Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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
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 cooling their heels in the Monastery: (2)
As of 2021-01-22 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?