http://www.perlmonks.org?node_id=991381


in reply to Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?

Now available with uracil flavour

use strict; use warnings; my @bas = ("A","G","C","T","U"); my @all = (); for my $a1(@bas){ for my $a2(@bas){ for my $a3(@bas){ push @all, "$a1$a2$a3\n"}} my @codon = grep !/(U.*T|T.*U)/, @all; for my $valid(@codon){ print $valid } }

EDIT: improved, codons with T + U off