in reply to Conditional Bitwise XOR(^) Operator in Matching Chars Count of Two Strings?

Mutate the Ns first:

use strict; use warnings; use Data::Dumper; my $s1 = "STCATTNNNSATCGCT"; my $s2 = "ATCGTCGSNNNNATCG"; $s1 =~ tr/N/n/; my $merge = $s1 ^ $s2; my $count = $merge =~ tr/\0//; print $count;

Prints:

4

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: Conditional Bitwise XOR(^) Operator in Matching Chars Count of Two Strings
by inman (Curate) on Nov 09, 2005 at 11:41 UTC
    Changing the transliteration line to tr/SACTG/_____/c; allows you to specify the characters that you want to keep. This maybe easier to work with in a biomed application.