sub make_log{ # make a log file my $log = shift; # open the log and stamp it open (my $log_file, '>>', $log) || die "Failed to open $log:\n$!"; print $log_file "\n------> log for $0\n------> ".scalar(localtime)."\n\n"; # make sure errors are put into the logfile # i.e. print STDERR "weird" ~ not in logfile # warn "freaky" ~ in logfile (and the screen) # die "AAaaarrrrrgh!" ~ in logfile $SIG{__WARN__} = sub {print $log_file @_;print STDOUT @_}; $SIG{__DIE__} = sub {print $log_file @_;print STDOUT @_;exit 1}; # return complete return $log_file; }