The only problem with that is the threshold is not exact, for example, if the threshold is instead .5, and the length of the query is three characters, I still come up with all the matches that have at least (1/3). I have tried fixing this to no avail, here is my attempt:
foreach my $key (keys %o) {
my $keydisplay=1;
my $target = $o{$key};
#my $threshold = 0.79;
my $searchlength = length $search;
my $truethreshold = int($searchlength * $threshold*100) /100; #(page46
+)
if ($searchlength - $truethreshold >= .005) {
$truethreshold += .01;
}
$searchlength = $truethreshold;
for my $position (0 .. (length ($target) - $searchlength)) {
my $test = substr $target, $position, $searchlength;
my $matched = ($test ^ $search) =~ tr/\x00//;
next if $matched < $truethreshold;
print "\t\tFound <$test> at position $position which matches in $m
+atched of $searchlength places\n";
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.