#!/home/perl5262/bin/perl

use strict;
use warnings;

# $Id$

use LWP::UserAgent;
use CPAN::Config;
use YAML;

my $ua = LWP::UserAgent->new();

my $cpan = 'http://www.cpan.org';
if ($CPAN::Config->{'urllist'}->[0]) {
    $cpan = $CPAN::Config->{'urllist'}->[0];
}

my $url = $cpan . '/authors/RECENT-1d.yaml';
my $response = $ua->get($url);

my (@list, @dev);

if ($response->is_success()) {
    my ($hashref, $arrayref, $string) = Load($response->decoded_content());

    foreach my $upl (sort { $a->{'epoch'} <=> $b->{'epoch'} } @{ $hashref->{'recent'} }) {
        next unless $upl->{'type'} eq 'new';

        my $path = $upl->{'path'};

        next if $path =~ /CHECKSUMS$/;
        next if $path =~ /\.meta$/;
        next if $path =~ /\.readme$/;

        if ($path =~ m!^id/./../(.*)$!) {
            $path = $1;
            if ($path =~ /\d_\d/) {
                push @dev, $path . $/;
            } else {
                push @list, $path . $/;
            }
        }
    }
} else {
    die $url, ': ', $response->status_line();
}

print @list;
print STDERR @dev;