Evil EU::MM hackery required

Andy Armstrong andy at hexten.net
Tue Mar 4 16:09:10 GMT 2008


On 4 Mar 2008, at 15:54, Andy Armstrong wrote:
> This works for EUMM:
>
> package MY;
>
> sub metafile {
>    my @lines = split /\n/, shift->SUPER::metafile_target( @_ );
>
>    my @exclude = qw( Devel::CheckOS );
>    my $pad     = ' ' x 4;
>    my $tail    = pop @lines;
>    if ( $lines[-1] =~ /^([^']*').*?('[^']*)$/ ) {
>        my ( $pre, $post ) = ( $1, $2 );
>        push @lines, map { "${pre}$_${post}" } (
>            'no_index:', "${pad}package:",
>            map { "${pad}${pad}- $_" } @exclude
>        );
>    } else {
>        die "Can't parse Makefile fragment";
>    }
>    push @lines, $tail;
>
>    return join "\n", @lines;
> }


Or less verbosely:

package MY;

sub metafile {
     my @lines = split /\n/, shift->SUPER::metafile_target( @_ );
     my @exclude = qw( Devel::CheckOS );
     my $pad     = ' ' x 4;
     die "Can't parse Makefile fragment"
       unless $lines[-2] =~ /^([^']*').*?('[^']*)$/;
     splice @lines, -1, 0, map { "$1$_$2" } (
         'no_index:', "${pad}package:",
         map { "${pad}${pad}- $_" } @exclude
     );

     return join "\n", @lines;
}

-- 
Andy Armstrong, Hexten






More information about the london.pm mailing list