NAME
Text::EditDistance::DamerauLevenshtein - Damerau-Levenshtein edit distance
SYNOPSIS
use Text::EditDistance::DamerauLevenshtein qw(dl_distance);
my $distance = dl_distance('flour', 'fluor');
# 1
DESCRIPTION
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.)
This module provides code to compute the Damerau-Levenshtein distance in a reasonably efficient manner.
Functions
- dl_distance FROM, TO
-
Computes and returns the Damerau-Levenshtein edit distance between between the FROM and TO strings. As usual with Perl, "characters" are taken to be (extended) Unicode code points: The distance between
xyzandx€zis 1.This function may fail by setting
$!and returningundefin the following cases (see Errno):EILSEQ-
One of the arguments is in an inconsistent state and the string data cannot be decoded. Normally this should not happen, but certain low-level Perl functions can be (ab-)used to create scalars containing invalid data.
ENOMEM-
The function was unable to allocate memory for its data structures. You're unlikely to see this unless your strings are truly gigantic.
AUTHOR
Lukas Mai, <lmai at web.de>
COPYRIGHT & LICENSE
Copyright 2026 Lukas Mai.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License (version 3) as published by the Free Software Foundation.
See https://www.gnu.org/licenses/agpl-3.0.html#license-text for more information.