Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Perl Advent Calendar Daily Installer

by jeffa (Bishop)
on Dec 06, 2003 at 14:11 UTC ( #312764=CUFP: print w/replies, xml ) Need Help??

Here is a quick and dirty little app that will query for the module of the day and install it via CPAN. You must have the proper permissions on your system to actually install the module. Better late then never. :)
use strict; use warnings; use CPAN; use Time::Piece; use LWP::Simple; use Data::Dumper; use HTML::TokeParser::Simple; use Lingua::EN::Numbers::Ordinate; use constant YEAR => 2003; my $time = localtime; unless ($time->year == YEAR && $time->mon == 12 && $time->mday < 25) { die "today does not have module\n"; } my $day = ordinate($time->mday); my $html = get("{[YEAR]}/$day"); my $p = HTML::TokeParser::Simple->new(\$html); while (my $t = $p->get_token) { if ($t->is_start_tag('div')) { my $attr = $t->return_attr; if (defined $attr->{class} && $attr->{class} eq 'moduletitle') { $t = $p->get_token; CPAN::Shell->install($t->as_is); } } }

Podmaster++ >:)


(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Perl Advent Calendar Daily Installer
by PodMaster (Abbot) on Dec 07, 2003 at 17:29 UTC
    This is a tad friendlier to the server
    use strict; use warnings; use LWP::Simple 'get'; use XML::Simple; use CPAN; my $xml = XMLin( get( '' ) ); my $item = shift @{ $xml->{channel}{item} }; CPAN::Shell->install($1) if $item->{title} =~ /-\s(\S+)$/;
    update: and here is the friendliest version possible
    use strict; use warnings; use LWP::Simple 'get'; use XML::Simple; use CPAN; CPAN::Shell->install( XMLin( get( '' ) ) ->{channel}{item}{title} );

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      And for those of us who like to avoid the expat-based modules and prefer libxml2:
      use strict; use warnings; use LWP::Simple 'get'; use XML::LibXML; use CPAN; CPAN::Shell->install( XML::LibXML ->new() ->parse_string( get( '' + ) ) ->findvalue( '/rss/channel/item/title' ) );
      Actually for the RDF feed currently provided you can just use //title as the XPath expression.

      Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://312764]
Approved by valdez
Front-paged by /dev/trash
and the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-04-25 23:23 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (466 votes). Check out past polls.