On 12/06/2013 11:33, lee wrote:
Jim Gibson <jimsgib...@gmail.com> writes:
On Jun 11, 2013, at 9:44 PM, lee wrote:
I've been googling for examples of how to create a sha-2 sum of a
file in perl without success. What I'm looking for is something
like:
$hash = create_sha2_sum( $filename);
Do you know of any examples I could look at? Or is there a better
way to figure out if a file has been modified?
The first thing to do would be to check the file size. If the file
size has changed, then the file has been modified. So you will want to
save the file size.
The file might be modified without changing its size ...
If the files sizes are the same, then you can compare some sort of
digest e.g. SHA. I haven't used any, so I cannot advise.
... so I'm better off by just using a hash which I'd need anyway.
No. If the file is real big, then calculating the hash (of the new file)
can take a long time. Which would be superfluous if the file size also
has changed.
I store: file size, fingerprint of first 256 bytes, fingerprint of total
file. So only if both the size and the light fingerprint are the same, I
need to check the full fingerprint.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/