Pinging Weblogs.com

This is the perl script that I have run by cron to check to see if the main file for Dave's Picks has changed, and if it has, send the ping to weblogs.com to let it know to check the file.

It also depends on a file, picks.check (though you could call it whatever you'd like) that contains the name of the file to be checked, and the last time a modification in it was noticed.

Ideally, the ping request would be stored in the picks.check file as well, so I could more easily manage multiple blogs, but I haven't needed to write that code yet, so I haven't gotten it done.
#!/usr/bin/perl -w

use LWP::Simple;

open(CFILE,"+<picks.check",) or die "Unable to open check file\n";

# read the files-to-check from the file I just opened
while(<CFILE>){
    chomp;
    @savedstats = split('\|');
    die "Wrong number of fields in \'$savedstats[0]\' line.\n" unless ($#savedstats == 1);

    @currentstats = (lstat($savedstats[0]))[9];

    open(F,$savedstats[0]) or die "Unable to open $savedstats[0]:$!\n";
    close(F);

    if (($currentstats[0] - $savedstats[1]) > 360) {        # more than 6 minutes
        # update the file holding the information
        seek (CFILE,0,0);
        truncate (CFILE,0);
        print CFILE $savedstats[0],"|",$currentstats[0],"\n";

        # and ping the server if everything else has worked
        $ping = "http://newhome.weblogs.com/pingSiteForm?" .
                "name=Dave\'s+Picks&" .
                "url=http://davespicks.com/";
        get($ping);
    }
}
close CFILE;
And here's picks.check
/var/www/davespicks.com/index.html|1006499626
Copyright 2009, Dave Polaschek. Last updated on Mon, 15 Feb 2010 14:07:51.