if((defined $upstream_putative_TSD)&&(defined $downstream_putative_TSD)) { # Check if the putative TSDs differ by just 1 mismatch or are perfect matches my $max_SNP = 1; my $diffCount = () = ( $upstream_putative_TSD ^ $downstream_putative_TSD ) =~ /[^\x00]/g; # print $upstream_putative_TSD, "\t", $downstream_putative_TSD, "\t", $diffCount, "\n"; # OK thus far # syntax idea from https://www.biostars.org/p/83978/ if ($diffCount <= $max_SNP) { my $upstream_putative_TSD_non_canonical_letter_count = $upstream_putative_TSD =~ tr/BDEFHIJKLMNOPQRSUVWXYZ//; # check to see whether upstream putative TSD contains anything but A/T/G/C, if yes, how many my $downstream_putative_TSD_non_canonical_letter_count = $downstream_putative_TSD =~ tr/BDEFHIJKLMNOPQRSUVWXYZ//; # check to see whether downstream putative TSD contains anything but A/T/G/C, if yes, how many if(($upstream_putative_TSD_non_canonical_letter_count==0)&&($downstream_putative_TSD_non_canonical_letter_count==0)) { print $_, "\n"; push @output, $_, "\n"; } } }