I'm not looking for the next Module::Build. I'm also not looking for make. What I'm looking for is some functionality that I've implemented myself in various bad and ad-hoc ways:

I'm generating some output files, which usually depend on one or more input files. And as this is a lengthy process, I only want to do that if some condition holds. That condition usually is that minimum last change timestamps of the output files is later than the maximum last change timetamp of all input files, that is, all output files were created later than the last input file was changed.

Now, the basic Perl code for this is

if ((stat($target))[9] < (stat($source))[9]) { ... do work ... }

but that only covers one target depending on one source file. Also, this gets complicated, because from time to time, you want to ignore all that smartness and force a clean slate by regenerating everything anyway:

if ($force or (stat($target))[9] < (stat($source))[9]) { ... do work ... }

So, what I'd like would be something that I preconfigure and which then handles those dependencies for me and invokes my callback. Maybe like this:

GetOptions( 'f' => \my $force, 'o' => \my $outdir, ); $outdir ||= 'thumbnails'; my $needs_remake = My::Dependencies::MTime->new( force => $force ); for my $source_image (@ARGV) { if ($needs_remake->([$source_image], ["$outdir/${source_image}_t.j +pg"])) { ... do work here }; };

... except that this API doesn't look quite usable to me, and worst of all, I would need to write it myself, again. So, maybe somebody has already written and tested that code for me, or maybe somebody is even a user of code that somebody else has written, and I don't know about the module. Please tell me whether the Easter Bunny has left this on CPAN already, and where.

I've already looked at the following modules:

Currently, I've somewhat uneasily settled on Decision::Depends with the following construct:

if (test_dep( -target => $thumbname, -depend => $info->{file} )) { ... }

... which still is a bit more verbose than I'd like it to be, but then again, I didn't need to write any code myself. Still, other recommendations are welcome!


In reply to A module encapsulating "make"-like checks by Corion

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.