in reply to Re: generating hash patterns for searching with one mismatch
in thread generating hash patterns for searching with one mismatch
Hi AR and Ratazong,
Thanks for the links to modules. But for me, "mismatch" only means "replacement". There should be no insertions or deletions. It seems to me that the module checks for all types of mismatches. no?
Hi Eliya,
I think I understand the method, but I doubt its efficient for my case. I forgot to mention that I have to perform the same for about 2e7 lines. Do you think it would be faster if we obtain all possible substrings for all lines?
For sake of this discussion, lets assume the line length is 50 and substring to check for each line is 20. So what I did was to create 21 different patterns, with the last 20 patterns replacing each character with a "." for regexp wild character comparison.
Then, its pretty straightforward:
for ($i=0; $i < "total lines"; $i++) { for $p (keys %pattern) { if ( $line[$i] =~ m/$p/ ) { # match; do something and break loop with "last;" } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: generating hash patterns for searching with one mismatch
by Eliya (Vicar) on Mar 17, 2011 at 12:29 UTC | |
by cedance (Novice) on Mar 18, 2011 at 09:11 UTC |