App-cpanoutdated-coro

 view release on metacpan or  search on metacpan

script/cpan-outdated-coro  view on Meta::CPAN


        if ($verbose) {
            printf "%-30s %-7s %-7s %s\n", $pkg, $inst_version, $version,
            $dist;
        }
        elsif ($print_package) {
            print "$pkg\n";
        }
        else {
            print "$dist\n";
        }
    }
    return;
}

# return true if $inst_version is less than $version
sub compare_version {
    my ( $inst_version, $version ) = @_;
    return 0 if $inst_version eq $version;

    my $inst_version_obj = eval { version->new($inst_version) }
    || version->new( permissive_filter($inst_version) );
    my $version_obj = eval { version->new($version) }
    || version->new( permissive_filter($version) );

    return $inst_version_obj < $version_obj ? 1 : 0;
}

# for broken packages.
sub permissive_filter {
    local $_ = $_[0];
    s/^[Vv](\d)/$1/;          # Bioinf V2.0
    s/^(\d+)_(\d+)$/$1.$2/;   # VMS-IndexedFile 0_02
    s/-[a-zA-Z]+$//;          # Math-Polygon-Tree 0.035-withoutworldwriteables
    s/([a-j])/ord($1)-ord('a')/gie;    # DBD-Solid 0.20a
    s/[_h-z-]/./gi;                    # makepp 1.50.2vs.070506
    s/\.{2,}/./g;
    $_;
}

# taken from cpanminus
sub which {
    my ($name) = @_;
    my $exe_ext = $Config{_exe};
    foreach my $dir ( File::Spec->path ) {
        my $fullpath = File::Spec->catfile( $dir, $name );
        if ( -x $fullpath || -x ( $fullpath .= $exe_ext ) ) {
            if ( $fullpath =~ /\s/ && $fullpath !~ /^$quote/ ) {
                $fullpath = "$quote$fullpath$quote";
            }
            return $fullpath;
        }
    }
    return;
}

sub getstore {
    my ( $url, $fname ) = @_;
    my $ua = LWP::UserAgent->new( parse_head => 0, );
    $ua->env_proxy();
    my $request = HTTP::Request->new( GET => $url );
    my $response = $ua->request( $request, $fname );
    if ( my $died = $response->header('X-Died') ) {
        die "Cannot getstore $url to $fname: $died";
    }
    elsif ( $response->code == 200 ) {
        return 1;
    }
    else {
        die "Cannot getstore $url to $fname: " . $response->status_line;
    }
}

sub zopen {
    IO::Zlib->new( $_[0], "rb" );
}

sub make_inc {
    my ( $base, $self_contained ) = @_;

    if ($base) {
        require local::lib;
        my @modified_inc = (
            local::lib->install_base_perl_path($base),
            local::lib->install_base_arch_path($base),
        );
        if ($self_contained) {
            push @modified_inc, @Config{qw(privlibexp archlibexp)};
        }
        else {
            push @modified_inc, @INC;
        }
        return @modified_inc;
    }
    else {
        return @INC;
    }
}

__END__

=head1 NAME

cpan-outdated-coro - faster C<cpan-outdated>

=head1 SYNOPSIS

    # usage is the same:=)

    # print the list of distribution that contains outdated modules
    % cpan-outdated-coro

    # print the list of outdated modules in packages
    % cpan-outdated-coro -p

    # verbose
    % cpan-outdated-coro --verbose

    # alternate mirrors
    % cpan-outdated-coro --mirror file:///home/user/minicpan/



( run in 0.900 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )