#!/usr/bin/perl -w use strict; ### config my ($HOME) = glob "~"; my $RSS_TEMP_DIR = "$HOME/lib/xml-rss-feed"; my $HTTP_CACHE_TEMP_DIR = "$HOME/lib/httpcache"; my $SIGNATURE = "$HOME/.signature"; ## for news posting: my ($HOST,$USER,$PASS) = qw(nntp.example.com merlyn guesswhat); ### end config use Encode qw(encode); use XML::RSS::Feed (); use HTTP::Cache::Transparent (); use LWP::Simple qw(get); use News::NNTPClient (); mkdir $RSS_TEMP_DIR, 0755 unless -e $RSS_TEMP_DIR; # one time init HTTP::Cache::Transparent::init({BasePath => $HTTP_CACHE_TEMP_DIR}); my $feed = XML::RSS::Feed->new (url => "http://search.cpan.org/uploads.rdf", name => "search.cpan.org", tmpdir => $RSS_TEMP_DIR, ); my @OUTPUT; my $xml = get($feed->url); $feed->parse($xml); for my $headline ($feed->late_breaking_news) { push @OUTPUT, $headline->headline . "\n"; push @OUTPUT, $headline->url . "\n"; my $desc = encode('ascii' => $headline->description); push @OUTPUT, "$desc\n" if defined $desc; push @OUTPUT, "----\n"; } exit 0 unless @OUTPUT; # we have something to say pop @OUTPUT; # remove final --- line my $c = News::NNTPClient->new(split /:/, $HOST); if ($USER) { $c->authinfo($USER, $PASS); } $c->postok or die "Cannot post to $HOST: $!"; @ARGV = $SIGNATURE; @OUTPUT = split /\n/, <<"END"; Newsgroups: comp.lang.perl.announce Followup-to: poster From: merlyn\@stonehenge.com (Randal Schwartz) Subject: new CPAN modules on @{[unpack 'A10 x10 A*', gmtime]} The following modules have recently been added to or updated in the Comprehensive Perl Archive Network (CPAN). You can install them using the instructions in the 'perlmodinstall' page included with your Perl distribution. @{[join '', @OUTPUT]} If you're an author of one of these modules, please submit a detailed announcement to comp.lang.perl.announce, and we'll pass it along. print "Just another Perl hacker," # the original -- @{[join '', <>]} END warn map "$_\n", @OUTPUT; $c->post(@OUTPUT) or warn "failed post!";