in reply to Re^2: Problem in "index" function in recognizing repeating substrings
in thread Problem in "index" function in recognizing repeating substrings

No, his code clearly gives 0 and 6. If you want 0 and 2, try this:
#!/usr/bin/perl use strict; my $str = 'ATCGATCGAT'; my @sub = qw(ATCG CGAT); my $id = 0; foreach (@sub) { $id = index($str, $_, $id); print "$id\n"; $id++; }
  • Comment on Re^3: Problem in "index" function in recognizing repeating substrings
  • Download Code