in reply to printing to a file

Why print to a file and to STDOUT (the screen). Why not just print to STDOUT and run your script like so ...
$ myscript.pl < inout > output
If you want to see the output on the screen do this ...
$ myscript.pl < input | tee output

Plankton: 1% Evil, 99% Hot Gas.