Unless this is homework/fun/practice
why not use BioPerl and Bio::Seq? For example you aren't handling all the confusion characters that might be seen, only support a single translation table etc. If this is some academic work you're better off avoiding that particular chunk of maintenance. About the only good thing in Bio Perl you can rely on is the data rep and IO code. I wouldn't trust most of the stats or other more algorithmic stuff, but all the basic format code is almost certainly more feature complete than what you will roll yourself.