get_uf_pix.pl



NAME

get_uf_pix.pl


DESCRIPTION

Get the last 5 comics from UserFriendly.org


COPYRIGHT

Copyright 2000-2007 Etienne LEMEE <coding AT etilem DOT net>

This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


#!/usr/bin/perl

use strict;
use LWP::Simple;
use Date::Simple qq/:all/;

my $i = 5;

my @mlab = qw(void jan feb mar apr may jun jul aug sep oct nov dec);

while ($i--) {
    my $d = today() - 1 - $i;
    #scheme: http://www.userfriendly.org/cartoons/archives/08jun/uf011614.gif
    my $url = 
    sprintf "http://www.userfriendly.org/cartoons/archives/%s%s/uf0%d%02d.gif",
            substr($d->year, 2),
            $mlab[$d->month],
            110 + $d->month,
            $d->day;
    print "getstore::$url failed!\n"
        unless(
            getstore(
                $url, 
                sprintf("%02d.gif", $i),
            )
        );
}