If that is your spec, then you should use the special array @- to report the position of the match. You don't need rindex for this (although it is possible that using rindex would be faster, even with the additional step of comparing positions, especially with a long string):
Output:perl -Mstrict -wE ' my $str = "ATCGATCGA..."; if ( $str =~ /([ATCG])\./ ) { say "$1 at $-[1]"; } '
See Variables related to regular expressions in perlvar.A at 8
Hope this helps!
update: simplified the re
In reply to Re^5: Proper usage of rindex function?
by 1nickt
in thread Proper usage of rindex function?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |