There are a number of typos/errors in the code but I'll just mention the major problems. The main issue is that you are not using open correctly. Generally speaking, to read a file you open a filehandle and read from it, then you close the filehandle (not the file). Most importantly, you need to specify the mode and use a lexical filehandle (I'll explain why). It is also good to test that these tasks succeeded. Here's how you open a file:
use strict;
use warnings;
use autodie;
open my $fh, '<', $file;
The autodie pragma (not required) allows you avoid typing "or die .." everywhere and the other pragmas are best practices (they are implicit in new Perl versions, strictures anyway) because we all make mistakes and Perl doesn't care. Then you read a line as Emily suggested (while (<$fh>) { ... }) and later close the filehandle:
close $fh;
If you forget to close the filehandle or try to declare the same filehandle later, no problem. Perl will halt and tell you that's not allowed. If you do this for reading a file:
open FH, $file;
and later do this print FH "some $data" anywhere in the code, your data is gone! Okay, technically Perl won't let you do that if you opened a file for reading (though I believe it once was possible), but even if you specify the mode you can still use that bare filehandle from anywhere because it has global scope. So, there is no reason to ever use a bare filehandle.
The other issue is that you are declaring a subroutine in a loop. This doesn't need to be seen before it is used so the common practice is to put that at the end of the file.
Unless this is an assignment, I would use a toolkit for translating the sequences so you can keep learning and practicing coding with smaller problems. Here is an example using Perl and EMBOSS:
use strict;
use warnings;
use Bio::Factory::EMBOSS;
my $usage = "$0 infile outfile";
my $infile = shift or die $usage;
my $outfile = shift or die $usage;
my $factory = Bio::Factory::EMBOSS->new;
my $sixpack = $factory->program('sixpack');
$sixpack->run({-sequence => $infile, -outseq => $outfile });
You can extend that code with what I mentioned above by opening the output and looking at the results, or whatever you need to do. If you want to implement your own solution, I would recommend looking at the BioPerl code since it has been thoroughly tested.