my $output_file = "script_out.txt"; open(FILE,">$output_file") or die "Unable to open $output_file for writing: $!"; print FILE "This will go to the file.\n"; print "This will go to browser.\n"; select FILE; print "This will go to the file, too.\n"; print STDOUT "This will go to the browser.\n";