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


in reply to Fast Way to Split String in to Chunk of Equal Length

Similar, but better like this, less error prone (and a little faster probably)

my $seq = qw(CCCTCTCTCCCAGGGGCA); my @parts = $seq =~ /[CGTAU]{3}/sg; foreach my $codon(@parts){print $codon," "}