Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I want to return the last position of the occuring substring in the string:
# 3 6 my $str = 'GCCGCTGCTGCTG'; my $sbst ='GCTGC'; my $pos = index($str,$sbst);
But my code above return 3 instead of 6. How can we achieve that?

Replies are listed 'Best First'.
Re: How to return last index position of a substring
by graff (Chancellor) on Aug 22, 2007 at 07:48 UTC
    I think you just need to check out rindex.