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
|
|---|