...
my @hits = ();
...
for ($i = 0; $i < $len; $i++) {
if (substr($doword,$i,1) ne "-") { substr($pat,$i,1) = "="; }
else { substr($pat,$i,1) = '-'; }
if (substr($doword,$i,1) eq ":") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq "'") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq ",") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq ".") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq "!") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq "?") { substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq "\"") {substr($pat,$i,1) = substr($doword,$i,1); }
if (substr($doword,$i,1) eq "_") { substr($pat,$i,1) = substr($doword,$i,1); }
for ($j = 0; $j < 26; $j++) {
if (substr($doword,$i,1) eq $letters[$j]) {
$hits[$j]++;
}
}
} # (end of first big "for loop"
for ($j = 0; $j < 52; $j++) {
if (defined $hits[$j]) {
if ($hits[$j] > 1) {
$got_a_pattern = 1;
}
}
} # (end of this little "for loop"
if ($got_a_pattern) {
...
####
...
for my $chr ( split //, $doword ) {
$pat .= ( $chr =~ /\W/ ) ? $chr : '=';
for my $ltr ( @letters ) {
$got_a_pattern++ if ( $chr eq $ltr );
}
}
if ($got_a_pattern) {
...
##
##
foreach (@template2) {
$_ =~ tr/ //d;
if ($_ eq " ") { next; }
push @template,$_;
}
##
##
tr/ //d;
push @template, $_ if ($_); # true when $_ is not an empty string