0

I was wondering if there is some kind of Perl module/package that allows for simple make-like functionality.

For example, is there something that can wrap a function that receives an input and an output and only perform it if the output doesn't exist or if it's older than the input?

A quick Google search introduced me to this:

http://perldoc.perl.org/ExtUtils/MakeMaker.html

But I am not sure if it's what I need (new to this... not much experience with makefiles either...).

If anyone has a specific direction or opinion, I'd be happy to hear it :)

Thanks!!!

4

1 回答 1

0

make可以很容易地确定什么是什么的依赖项,但您并没有要求这样做。我认为以下就足够了:

sub make {
   my ($func, $targ, @deps) = @_;
   my $M_targ = -M $targ;
   for my $dep (@deps) {
      my $M_dep = -M $dep
         or die("Error stating dependency $dep: $!\n");

      if (-M $_ > $M) {
         $func->($targ, @deps);
         last;
      }
   }
}

make(\&func, $targ, @deps);

-M获取文件的修改时间。

于 2013-05-27T19:27:59.903 回答