Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: finding the last occurence of substring in string

by johngg (Abbot)
on Jul 26, 2012 at 16:15 UTC ( #983862=note: print w/ replies, xml ) Need Help??


in reply to finding the last occurence of substring in string

I'm not sure I'm understanding correctly what you want to do but this gives the answer you seem to want.

$ perl -Mstrict -Mwarnings -E ' > my $last; > my $pos; > my $stream = q{0123??6789??????}; > map { $last = $pos unless m{\?\?}; $pos ++ } > unpack q{(a2)*}, $stream; > say $last;' 4 $

I hope this is helpful but perhaps you could clarify your requirement if I have misunderstood.

Cheers,

JohnGG


Comment on Re: finding the last occurence of substring in string
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-08-29 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (278 votes), past polls