in reply to Log's and MD5 Hashes
#!/usr/bin/perl -w use Digest::MD5; open CONFIGFILE, "<config.ini" or die "I cant open the config file."; open RESULTS, ">md5TEMP" or die "I cant write the MD5's temp file."; my $a = 0; my $b = 0; my $change=0; open OLDMD5, "<md5" or die "I cant read the MD5's file."; #Do the MD5 Dance while (<CONFIGFILE>) { chomp; $file = $_; open(FILE, $file) or die "Can't open $file"; binmode(FILE); $md5 = Digest::MD5->new; while (<FILE>) { $md5->add($_); } close(FILE); print RESULTS $md5->b64digest, " ", $file, "\n"; #print $md5->b64digest, "\n"; $a=$a+1; } close RESULTS; close CONFIGFILE; open RESULTS, "<md5TEMP" or die "I cant read the MD5's temp file."; my @file1 = <RESULTS>; my @file2 = <OLDMD5>; close OLDMD5; #See what's different while ($a != $b) { if ($file1[$b] ne $file2[$b]) { print $file1[$b]; $change=1; } $b=$b+1; } #If they differ, then update the oldMD5 file to the newest one. $b=0; if ($change eq 1) { open OLDMD5, ">md5" or die "I cant write the MD5's file."; while ($a != $b) { print OLDMD5 $file1[$b]; $b=$b+1; } } close RESULTS; close OLDMD5;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log's and MD5 Hashes -- FINALLY DONE
by Zaxo (Archbishop) on Jan 31, 2002 at 08:09 UTC | |
|
Re: Log's and MD5 Hashes -- FINALLY DONE
by Anonymous Monk on Jan 31, 2002 at 08:24 UTC |