Instantly share code, notes, and snippets.

Embed
What would you like to do?
$|++;
use warnings;
use Text::LevenshteinXS qw(distance);
for (qx!cat nappis.txt!) {
$merkki{$2} = $1 if (/^(.+) ([01]+)/);
}
while (<>) {
chomp();
$pienin = "";
for $vertai (keys %merkki) {
$pienin = $vertai if ($pienin eq "" or distance($_, $vertai) <= distance($_, $pienin));
}
print ($merkki{$pienin} // "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment