The preferred method for this is to handle redirection via the command line, e.g.
perl -w my_program.pl > my_output.txt
If you want to also include stderr output then you can do this (assuming your shell is bash):
perl -w my_program.pl &> my_output.txt