monkfan has asked for the wisdom of the Perl Monks concerning the following question:
Returns:#!/usr/bin/perl -w use strict; my $str = 'NNNNNATCGNNNNATCG'; my @substr = qw(ATCG ATCG); foreach (@substr) { my $id = index($str,$_); print "$id\n"; }
How can I overcome this problem such that the index function can recognize the second substrings in the correct position? Returning this instead:5 5
5 13
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem in "index" function in recognizing repeating substrings
by reasonablekeith (Deacon) on Sep 02, 2005 at 09:47 UTC | |
|
Re: Problem in "index" function in recognizing repeating substrings
by Tanalis (Curate) on Sep 02, 2005 at 09:35 UTC | |
|
Re: Problem in "index" function in recognizing repeating substrings
by ysth (Canon) on Sep 02, 2005 at 12:00 UTC | |
by reasonablekeith (Deacon) on Sep 02, 2005 at 14:29 UTC | |
by monkfan (Curate) on Sep 02, 2005 at 14:52 UTC | |
by saberworks (Curate) on Sep 02, 2005 at 16:05 UTC |