in reply to Re^2: Translation Substring Error (updated)
in thread Translation Substring Error

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;