#!/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);
    if (getstore($url, ".$0")) {
        my $file = sprintf("%02d.gif", $i);
        unlink $file;
        rename ".$0", $file;
    } else {
        print "getstore::$url failed!\n" 
    } 
}

=head1 NAME

B<get_uf_pix.pl>

=head1 DESCRIPTION

Get the last 5 comics from UserFriendly.org

=head1 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.

=cut
