If you want to do easy restart properties for failed jobs, logging @ARGV will not help you. At least, I have cases where there is a distinct difference, passing time, which makes reusing the exact command line switches unfeasible in my case.

I have lots of "convenience" command line switches, mostly used for crontab entries which select reporting dates:

./my_job --date prev-workday foo bar

Of course, if such a job has failed, restarting it with that command line is not useful as the prev-workday now may well be a different date than what it was when the job failed.

To solve this problem, I have come to the pattern of logging the parameters of the "main subroutine" for the job for restarting. The main subroutine must be called with what I call "effective parameters", that is, no more relative dates but only absolute information:

GetOptions( 'date:s' => \my $reporting_date, ); $reporting_date||= $today; $reporting_date= Corion::Calendar->dwim( $date )->ymd; # convert symbo +lic names to YYYYMMDD generate_report( reporting_date => $reporting_date, ... );

generate_report then logs its parameters for easy restarting, and in the case of an error usually outputs a command line that can be pasted verbatim into a console session verbatim to restart the job.


In reply to Re: What are (popular) modules that access/modify @ARGV? by Corion
in thread What are (popular) modules that access/modify @ARGV? by frozenwithjoy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.