my $step = 5; my $bound = int (length($str1) / $step); for my $i (0 .. $bound) { if (substr($str1, ($i * $step), $step) ne (substr($str2, ($i * $step), $step)) { $val++; } }