use String::Approx 'adist'; $dist = adist("pattern", $input);