in reply to shift or die unless
the script will run whether the arg is there or not and if its not, check the modification date of a file and if its a week old, run a certain sub.
I don't see any indication of trapping an error condition, so why do you have: die "takes one arg"? If I understand your description, the idea is:
If the "nothing to do" condition should really be treated as a failure, use die instead of warn with the "Usage: ..." message. You would also use die (or Carp::croak) in your subroutines, or check their return values and die after the call, if necessary.if ( @ARGV ) { do_something( shift ); } elsif ( -M $file > 7 ) { do_something_else(); } else { warn "Nothing to do ($file is recent, and you gave no arg to work +on)\n"; warn "Usage: $0 [optional_arg_that_does_what_exactly]\n"; } # default exit status will be "0" (success)
|
|---|