I have submitted a wish-list bug-report at rt.cpan.org for ExtUtils::MakeMaker regarding a compliment option to the PM_FILTER option for Perl Module files called PL_FILTER.
I would like to get everyone else's opinions on the matter as well. If you don't have any idea as to what PL_FILTER would do, read the following POD and think of a ".pl" script instead of a ".pm" (or even ".PL") script. <...> PM_FILTER A filter program, in the traditional Unix sense (input from stdin, output to stdout) that is passed on each .pm file during the build (in the pm_to_blib() phase). It is empty by default, meaning no fil- tering is done. Great care is necessary when defining the command if quoting needs to be done. For instance, you would need to say: {'PM_FILTER' => 'grep -v \\"^\\#\\"'} to remove all the leading coments on the fly during the build. The extra \\ are necessary, unfortunately, because this variable is interpolated within the context of a Perl program built on the com- mand line, and double quotes are what is used with the -e switch to build that command line. The # is escaped for the Makefile, since what is going to be generated will then be: PM_FILTER = grep -v \"^\#\" Without the \\ before the #, we'd have the start of a Makefile com- ment, and the macro would be incorrectly defined. </...> I've attached a patch for ExtUtils::MakeMaker version 6.16 that implements this feature (yes the patch has been submitted to rt.cpan.org, but that one was flawed and I've since corrected the issue, thus the -2 in the patch filename, and yes I have submitted the updated patch to [EMAIL PROTECTED] but have yet to receive a response from anyone). And yes the patch updates the POD to suite the changes :) Thanks! -- Kevin C. Krinke <[EMAIL PROTECTED]> Open Door Software Inc.
diff -ur ./Changes ../ExtUtils-MakeMaker-6.16/Changes --- ./Changes 2003-08-18 04:40:00.000000000 -0400 +++ ../ExtUtils-MakeMaker-6.16/Changes 2003-09-06 08:24:40.000000000 -0400 @@ -1,3 +1,8 @@ +6.17 Sat Sep 6 08:00:00 EST 2003 + * Adding in support for PL_FILTER which is a compliment to PM_FILTER + except for .pl files. [Kevin C. Krinke] + * Documented PL_FILTER in all the expected places. [Kevin C. Krinke] + 6.16 Mon Aug 18 01:39:51 PDT 2003 * Fixing the max exec length for Windows to account for old versions of nmake (the one you can download for free from MS). diff -ur ./lib/ExtUtils/Install.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/Install.pm --- ./lib/ExtUtils/Install.pm 2003-06-05 04:04:31.000000000 -0400 +++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/Install.pm 2003-09-10 04:06:42.000000000 -0400 @@ -395,14 +395,15 @@ =item B<pm_to_blib> pm_to_blib(\%from_to, $autosplit_dir); - pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd); + pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd, $pl_filter_cmd); Copies each key of %from_to to its corresponding value efficiently. Filenames with the extension .pm are autosplit into the $autosplit_dir. $filter_cmd is an optional shell command to run each .pm file through prior to splitting and copying. Input is the contents of the module, -output the new module contents. +output the new module contents. $pl_filter_cmd is the same as the +$fileter_cmd except that it works on .pl files instead of .pm files. You can have an environment variable PERL_INSTALL_ROOT set which will be prepended as a directory to each installed file (and directory). @@ -410,7 +411,7 @@ =cut sub pm_to_blib { - my($fromto,$autodir,$pm_filter) = @_; + my($fromto,$autodir,$pm_filter,$pl_filter) = @_; use File::Basename qw(dirname); use File::Copy qw(copy); @@ -458,10 +459,20 @@ if ($need_filtering) { run_filter($pm_filter, $from, $to); print "$pm_filter <$from >$to\n"; + } + + # When a pl_filter is defined, we need to run_filter just like with + # pm_filters. -- KCK, Sep. 6, 2003 + my $need_pl_filtering = defined $pl_filter && length $pl_filter && + $from =~ /\.pl$/; + if ($need_pl_filtering) { + run_filter($pl_filter, $from, $to); + print "$pl_filter <$from >$to\n"; } else { - copy($from,$to); - print "cp $from $to\n"; + copy($from,$to); + print "cp $from $to\n"; } + my($mode,$atime,$mtime) = (stat $from)[2,8,9]; utime($atime,$mtime+$Is_VMS,$to); chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$to); diff -ur ./lib/ExtUtils/MM_Unix.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MM_Unix.pm --- ./lib/ExtUtils/MM_Unix.pm 2003-08-14 21:28:42.000000000 -0400 +++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MM_Unix.pm 2003-09-06 07:51:43.000000000 -0400 @@ -486,7 +486,7 @@ for my $macro (qw/ FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT - LDFROM LINKTYPE PM_FILTER + LDFROM LINKTYPE PM_FILTER PL_FILTER / ) { next unless defined $self->{$macro}; @@ -3256,7 +3256,7 @@ }; my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']); -pm_to_blib([EMAIL PROTECTED], '$autodir', '\$(PM_FILTER)') +pm_to_blib([EMAIL PROTECTED], '$autodir', '\$(PM_FILTER)', '\$(PL_FILTER)') CODE my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}}); diff -ur ./lib/ExtUtils/MakeMaker.pm ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MakeMaker.pm --- ./lib/ExtUtils/MakeMaker.pm 2003-08-14 21:28:55.000000000 -0400 +++ ../ExtUtils-MakeMaker-6.16/lib/ExtUtils/MakeMaker.pm 2003-09-06 07:57:29.000000000 -0400 @@ -224,7 +224,7 @@ MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE PERL_SRC PERM_RW PERM_RWX - PL_FILES PM PM_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC + PL_FILES PM PM_FILTER PL_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC PPM_INSTALL_SCRIPT PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG XS_VERSION clean depend dist dynamic_lib linkext macro realclean @@ -1911,6 +1911,29 @@ Without the \\ before the #, we'd have the start of a Makefile comment, and the macro would be incorrectly defined. +=item PL_FILTER + +A filter program, in the traditional Unix sense (input from stdin, output +to stdout) that is passed on each .pl file during the build (in the +pm_to_blib() phase). It is empty by default, meaning no filtering is done. + +Great care is necessary when defining the command if quoting needs to be +done. For instance, you would need to say: + + {'PL_FILTER' => 'grep -v \\"^\\#\\"'} + +to remove all the leading coments on the fly during the build. The +extra \\ are necessary, unfortunately, because this variable is interpolated +within the context of a Perl program built on the command line, and double +quotes are what is used with the -e switch to build that command line. The +# is escaped for the Makefile, since what is going to be generated will then +be: + + PL_FILTER = grep -v \"^\#\" + +Without the \\ before the #, we'd have the start of a Makefile comment, +and the macro would be incorrectly defined. + =item POLLUTE Release 5.005 grandfathered old global symbol names by providing preprocessor