in reply to Comparing string characters

It seems like you're interested in the edit distance. There are several different algorithms, and the most well-known is Levenshtein distance, implemented for example by Text::Levenshtein.
#!/usr/bin/perl use warnings; use strict; use Text::Levenshtein qw{ distance }; use Test::More tests => 3; is distance('ABCGE', 'ABCGE'), 0; is distance('ABCGE', 'FGCGB'), 3; is distance('ABCGE', 'JHAGT'), 4;

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Comparing string characters
by dnamonk (Acolyte) on Nov 22, 2021 at 18:19 UTC
    Thanks. That was really helpful :)
Re^2: Comparing string characters
by LanX (Saint) on Nov 22, 2021 at 17:42 UTC
    Levenshtein might be overkill, I can't see a requirement for "edit distance" in these samples

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery