in reply to perl: comparing words in the arrays
You can use an old trick: XOR the two strings and count the number of non-null characters:
#!/usr/bin/perl use strict; use warnings; my @seq1 = qw(ATGC TGCT GCTA CTAA TAAC); my $seq2 = 'GTCA'; for my $seq (@seq1) { my $count = ($seq ^ $seq2) =~ tr/\0//c; print "$seq $count\n"; }
|
|---|