Well, if it's just finding matches inside the same array,
it's just a variation on finding uniques in an array.
Here's one way of solving it:
#!/usr/bin/perl
use strict;
use warnings;
my @array = qw /TATG GTTC GAAC AATA/;
# DNA's tend to be loooooooooooooooong, so we create a lookup
# table to calculate the reversed inverse.
my %table;
my @chars = qw /A C G T/;
foreach my $c1 (@chars) {
foreach my $c2 (@chars) {
foreach my $c3 (@chars) {
foreach my $c4 (@chars) {
my $val = reverse my $key = "$c1$c2$c3$c4";
$val =~ y/ACGT/TGCA/;
$table {$key} = $val;
}
}
}
}
my %tmp; @tmp {@array} = ();
my @matches = grep {exists $tmp {$table {$_}}} @array;
print "@matches\n";
__END__
Abigail |