develooper Front page | perl.perl5.porters | Postings from April 2006

Pruning jhi's cpd output

From:
andy
Date:
April 16, 2006 17:21
Subject:
Pruning jhi's cpd output
Message ID:
20060417002131.GA4836@petdance.com
There's a lot of dupe code in jhi's run that I'm not interested in.
Boilerplate between NetWare and win32 and wince doesn't interest me.
Ditto all the ppport.h copies running around.

So here's a little pruner to weed it all out.

xoxo,
Andy


#!/usr/bin/perl -w

use strict;
use warnings;

my $DELIM = ("=" x 69) . "\n";

local $/ = $DELIM;

while ( my $chunk = <> ) {
    my @lines = split( /\n/, $chunk );

    s[/Users/jhi/Desktop/Download/pmd-3.6/perl-5.9.x/][] for @lines[1..2];

    next if noisy( @lines[1..2] );

    #print join( "\n", @lines[1..2], "", "" );
    print join( "\n", @lines, "" );
}

sub noisy {
    my @lines = @_;

    return 1 if $lines[0] =~ /ppport.h$/;

    my $nbad = 0;
    for ( @lines ) {
        ++$nbad if m[NetWare|win(ce|32)/];
    }
    return 1 if $nbad == 2;

    $nbad = 0;
    for ( @lines ) {
        ++$nbad if m{(per|mad)ly\.c};
    }
    return 1 if $nbad == 2;

    $nbad = 0;
    for ( @lines ) {
        ++$nbad if m{/a2p\.c$};
    }
    return 1 if $nbad == 2;

    return 0;
}

-- 
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About