The Damerau-Levenshtein edit distance between two strings is the minimum number of operations required to transform one string into the other. The allowed operations are: insertion: adding a single character anywhere in the string deletion: removing any single character from the string substitution: changing any single character into some other character transposition: swapping any two adjacent characters (The related Levenshtein distance does not include transposition operations.) I found a CPAN module to compute this edit distance, Text::Levenshtein::Damerau::XS . But I wasn’t entirely happy