in reply to scp cronjob
please let me know if the sub can be improved.###################################################################### +######### sub do_log { ###################################################################### +######### my $output_string = ""; my $log_file = "/some/where"; if (not defined $_[0]) { $output_string = "\n"; } else { $output_string = "$$: " . scalar (gmtime ()) . ": " . join ("" +, @_) . "\n"; } print STDERR $output_string unless ($opts{n}); unless ($opts{l}) { if (-e $log_file) { open (LOGFILE, ">> $log_file") or die "cannot write log [$ +log_file][$!]"; } else { open (LOGFILE, "> $log_file") or die "cannot create log [$ +log_file][$!]"; } print LOGFILE $output_string; close (LOGFILE); } }
|
|---|