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"; }
In reply to Re: perl: comparing words in the arrays
by choroba
in thread perl: comparing words in the arrays
by GSperlbio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |