Your index function always starts from the beginning of the string, so at best has only two distinct values.
You probably want the pos function and a while loop. Collecting an array of K's and R's is not getting you much. I'm going to rewrite the regex as a character class, though there's nothing wrong with yours.
my $string = 'LPNTGVTNNAYMPLLGIIGLVTSFSLLGLXKARRD'; while ($string =~ /([KR])/g) { print pos($string) - length($1), $/; } __END__ 30 32 33
After Compline,
Zaxo
In reply to Re: match all instances?
by Zaxo
in thread match all instances?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |