Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Re: Re: Writing to DATA

by iguanodon (Priest)
on Nov 14, 2003 at 18:14 UTC ( #307138=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://307138]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2018-04-22 05:33 GMT
Find Nodes?
    Voting Booth?