in reply to Pattern matching problem
For literal strings, I like index,
There is some tricky fenceposting there with $loc. The %location hash will wind up containing all the locations in the string of each $quart which is found at least once. You will be able to test if a string is present at all with exists $location{$str}.my ($loc, %location) = -1; for ($quart1, $quart2) { # or better, @quart while (-1 != $loc = index $sequences, $_, $loc + 1) { push @{$location{$_}}, $loc; } }
This code doesn't care at all about overlap, will easily find the presence of both in those cases.
After Compline,
Zaxo
|
|---|