use v5.12; use warnings; use Data::Dump qw/pp dd/; use Test::More; sub distance { my ( $x,$y ) = @_ ; return scalar (("$x" ^ "$y") =~ tr/\0//c ); } my $x ='ABCGE ABCGE'; my $y ='ABCGE FGCGB'; my $z ='ABCGE JHAGT'; is( distance($x,$y) => 3, "by row"); is( distance($x,$z) => 4, "by row"); while (){ my @col = split; is( distance($col[0],$col[1]) => $col[2],"by col"); } done_testing; __DATA__ ABCGE ABCGE 0 ABCGE FGCGB 3 ABCGE JHAGT 4