[Chicago-talk] Script comments

Steve Peters steve at fisharerojo.org
Tue Jan 17 11:54:08 PST 2006


On Tue, Jan 17, 2006 at 01:13:43PM -0600, Young, Darren wrote:
> Finally have come close to finishing my parallel backup script. Thanks
> for the Parallel::ForkManager idea, works great. Love to get some review
> and comments on the script from those that are better than me at this
> (before it gets shoved into production).
> 

Three quick comments since I'm assuming you have unit tests for this 
code to show that its working...

1.  Pod::Usage - live it, learn it, love it.
2.  I saw you were using POSIX::strftime() one place in your script.
    So why do you have this code in there too.  Also, do you really want
    to fail your backup if someone writes out an empty log message.
3.  Why is your program have its own unique logging function?  A package
    would probably be more useful, and let you put all your logs in a 
    single parsable format.

Steve Peters
steve at fisharerojo.org

 357  sub logmsg {
 358      my $message = shift;
 359      if ( ! $message ) {
 360          print "logmsg: you must supply a message!\n";
 361          exit(127);
 362      }
 363      my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
 364
 365      $mon   += 1;
 366      $year  += 1900;
 367      $mon   = sprintf("00", $mon);
 368      $mday  = sprintf("00", $mday);
 369      $hour  = sprintf("00", $hour);
 370      $min   = sprintf("00", $min);
 371      $sec   = sprintf("00", $sec);




More information about the Chicago-talk mailing list