in reply to Compare file content with a variable content
But to answer your question, change#!/usr/bin/perl -w use strict; use MD5; use LWP::Simple; my $url='http://www.mrnick.binary9.net'; my $file='sitechanges.txt'; ## grab the contents my $content=get($url) || die $!; ## grab the MD5 sum from our datafile my $oldmd5=''; if (-f $file) { open(IN,"<$file") || die $!; $oldmd5=<IN>; close IN; } ## generate the new MD5 my $newmd5=MD5->hexhash($content); ## same? if ($newmd5 ne $oldmd5) { ## file has change ... do something ## .... (insert your mailing code here) ## then save the new md5 open(OUT,">$file") || die $!; print OUT $newmd5; close OUT; }
toif ($modified = $string) { print "the file is the same";
if ($modified eq $string) { print "the file is the same";
Update: The size of the files you are grabbing IS very important. 18MB is quite bit for casual downloading for comparison. In that case, I would also rely on the headers returned from HEAD (including Content-Length).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Compare file content with a variable content
by Skyhawlk (Initiate) on May 20, 2001 at 15:27 UTC | |
|
Re: Re: Compare file content with a variable content
by Skyhawlk (Initiate) on May 20, 2001 at 11:11 UTC | |
by Beatnik (Parson) on May 20, 2001 at 11:50 UTC |