in reply to Re: Re: Writing to DATA in thread Writing to DATA
Inline::Files is pretty easy, I use it for exactly what you describe:
use Inline::Files;
#...
# Get the cached MD5 sum
open MD5_SUM or die $!;
my $prev_md5_sum = <MD5_SUM>;
$prev_md5_sum =~ s!\s*!!sg;
close MD5_SUM or die $!;
# Get the current MD5 sum
open(FH, $file) or die "Can't open '$file': $!";
binmode(FH);
my $curr_md5_sum = Digest::MD5->new->addfile(*FH)->hexdigest;
close FH;
# Quit if this file has changed since the last run
die "MD5 sums do not match" unless $curr_md5_sum eq $prev_md5_sum;
# Write the new checksum
use vars qw($MD5_SUM);
open MD5_SUM, ">$MD5_SUM" or die $!;
print MD5_SUM $curr_md5_sum;
close MD5_SUM or die $!;
__END__
maybe have some other stuff here...
__MD5_SUM__
f8889c135c8342fc394616c3d34f37c2
|