in reply to Re^2: Makefile.PL does not always install changed file
in thread Makefile.PL does not always install changed file
Thank you for updating your post, but unfortunately, I don't think it's representative, since it doesn't seem to reproduce the issue: it doesn't run because WriteMakeFile should be WriteMakefile, and at least on my version of make, the all: myconfig line causes problems. Anyway, the following jumps out at me:
return <<END; \tperl -e 'open(IN, "<" , "$tmpl"); open(OUT, ">", "$config"); while(< +IN>) { print OUT $_; } close(IN); close(OUT);' END
Because the $_ will be interpolated, i.e. the generated Makefile will look like "while(<IN>) { print OUT ; }" (or worse, if $_ happens to contain a value, that'll become part of the Makefile). To get what you intended in the Makefile, you need to write print OUT \$\$_; - the \$ to escape the backslashes for Perl, and the $$ to escape the $ for make.
However, this is still brittle in several ways. Simply interpolating "$tmpl" and "$config" will fail if those variables contain any characters special to Perl or make, and you're not checking the open for errors. Plus, the command I quoted above is really just a cp. The first of those issues could theoretically be solved by using a module such as Data::Dump to write the $tmpl and $config variables to a Perl file, but I agree with stevieb that this might be better handled using a configuration file in a different format.
Getting back to the problem you describe in the root node, since this doesn't seem to be a representative example, I can only guess: perhaps the myconfig target isn't getting called every time?
|
|---|