I do like the regex solution though, it's quite elegant.
You can combine my second and third suggestions (for nonexistent codes, this uses the defined-or solution I showed here, the exists solution would work as well):
(my $amino_acid = $seq) =~ s{(...)} { $genetic_code{$1} // 'X' }esg; return $amino_acid;
In reply to Re^3: Translation Substring Error
by haukex
in thread Translation Substring Error
by FIJI42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |