my $outfile = "/home/output.htm"; open STDOUT, ">", $outfile or die "Couldn't write to '$outfile': $!"; ... rest of the program