in reply to Opening files, comparing strings. Should be simple!?
$targetseq =~ /.*$probe.*/
simplies to
$targetseq =~ /$probe/
but you probably want to escape the stuff in $probe (which should fix the problem), leaving you with
$targetseq =~ /\Q$probe\E/
which is the same thing as
index($targetseq, $probe) != -1
So
if ($targetseq=~ /.*$probe.*/) { $start = index($targetseq, $probe); push(@matchregion,$start); }
becomes
$start = index($targetseq, $probe); push(@matchregion, $start) unless $start == -1;
I didn't look at improving your alogirthm, just fixing the problem you mentioned (the contents of $probe being treated as a regexp).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Opening files, comparing strings. Should be simple!?
by PD (Initiate) on Jan 04, 2005 at 18:17 UTC |