in reply to Compare file content with a variable content

I have a similar script that uses LWP::Simple, Digest::MD5 and DBI. I basically store the page checksum in the DB, which is a pretty good method to check if the file has changed. Comparing the full page is kinda overkill IMHO.
Update: pretty similar to mr.nick's solution above...
Update2: I was actually considering posting this under CUFP a few days ago...
#!/usr/bin/perl -w use strict; use DBI; use LWP::Simple; use Digest::MD5 qw(md5 md5_hex md5_base64); my $dbh = DBI->connect("dbi:mysql:database", "user", "password") || di +e "Can't connect"; my $sth = $dbh->prepare("select url from sites"); $sth->execute(); my $url = undef; $sth->bind_col(1,\$url); my @urls = (); while($sth->fetch()) { push(@urls, $url); } $sth->finish(); if (@ARGV) { my $url = $ARGV[0]; my $page = get($url); my ($title) = $page =~ /<TITLE>(.*?)<\/TITLE>/i; my $digest = md5_hex($page); my $date = time(); $title =~ s/\'/\\\'/g; my $q = join ("','",$title,$url,$digest,$date); $q = "'".$q."'"; $sth = $dbh->prepare("insert into sites values ('$title','$url','$di +gest','$date')"); $sth->execute(); } $sth->finish(); foreach my $url (@urls) { my $page = get($url); print $url,"\n"; my $digest = md5_hex($page); $sth = $dbh->prepare("select checksum from sites where url = '$url'" +); $sth->execute(); my $checksum = undef; $sth->bind_col(1,\$checksum); while($sth->fetch) { if ($checksum ne $digest) { my $date = time(); my ($title) = $page =~ /<TITLE>(.*?)<\/TITLE>/i; my $q = qq|url = "$url", name = "$title", checksum = "$digest", +date = "$date"|; my $sth2 = $dbh->prepare("update sites set $q where url = '$url' +"); $sth2->execute(); } } $sth->finish(); } $dbh->disconnect || die "Disconnection failed";

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.