in reply to generating hash patterns for searching with one mismatch
Any vaguely recent Perl has the "trie optimization" which will automatically merge the branches. You can run with perl -Mre=debug to see what's going on.$pat = join '|', reverse sort keys %pattern; $pat = qr/$pat/;
EDIT: For more than 1-2 mismatches, you'll need to do something a bit fancier, either constructing a suffix tree or using seeds (you can show that any k-mismatch pattern must contain a substring of your original pattern of at least a certain length). I don't know of a Perl module off-hand to do either.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: generating hash patterns for searching with one mismatch
by cedance (Novice) on Mar 18, 2011 at 09:21 UTC | |
by educated_foo (Vicar) on Mar 18, 2011 at 16:09 UTC |