So here I am ripping all the htmlifypods code out of MakeMaker and I
come upon this:

    #
    # When we eval a Makefile.PL in a subdirectory, that one will ask
    # us (the parent) for the values and will prepend "..", so that
    # all files to be installed end up below OUR ./blib
    #
    %Prepend_dot_dot =
        qw(

           INST_BIN 1 INST_EXE 1 INST_LIB 1 INST_ARCHLIB 1 INST_SCRIPT 1
           MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1 PERL_SRC 1 
           PERL 1 FULLPERL 1

          );

why its written in this clumsy way, I dunno.  Maybe at one point there
were different values for each key.

I'd rewrite it like this:

    %Prepend_dot_dot = map {($_ => 1)}, qw(INST_BIN INST_EXE ...);


But that's not what makes it interesting.  %Prepend_dot_dot is defined
at the end of ExtUtils::MakeMaker->full_setup.  Its a global and its
hard-coded.  The only place its used is in ExtUtils::MakeMaker->new
(maybe it was used in other placed before).  So there's really no more
reason for it to be a global.  Yay!  One less global.

Finally, if we look at where its used we see:

        for $key (keys %Prepend_dot_dot) {

and that's the only reference to it.  So... we have awkward code to
make a hash which we then flatten into an array.


In the end, we're left with a simple array declaration.

    @Prepend_dot_dot = qw(
           INST_BIN INST_EXE INST_LIB INST_ARCHLIB INST_SCRIPT
           MAP_TARGET INST_MAN1DIR INST_MAN3DIR PERL_SRC
           PERL FULLPERL
    );

and a simple foreach loop:

    for my $path (@Prepend_dot_dot) {

I'm leaving it global since I haven't quite decided what to do about
breaking up full_setup() and its not a priority.

And MakeMaker is nudged another inch closer to sanity.


PS I'm planning on doing a talk about all this, so I'm sort of using
this list as a running notebook.  I'm also hoping other people will
join in the fun and start fixing these anachronisms along with me.

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
I know you get this a lot, but what's an unholy fairy like you doing in a
mosque like this?

Reply via email to