open(LOG_FILE,">$log_file") || die "Unable to open $log_file: $!\n"; my $old_err = *STDERR; my $old_out = *STDOUT; # Redirecting STDERR and STDOUT to the log file handle *STDERR = \*LOG_FILE; *STDOUT = \*LOG_FILE;