use Text::Levenshtein qw(distance); $distance = distance ($id1, $id2);