use Text::Levenshtein qw/distance/; sub off_by_one { 1 == distance("foo bar baz", shift); }