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.

> A good place to look for Perl modules is the Comprehensive Perl
> Archive Network (CPAN). Go to http://search.cpan.org and enter SHA
> into the search box. This will give you modules such as Digest::SHA,
> which seems to do what you want.
>
> Next, install the module on your system. On a Unix-like system or one
> that supports command-line input, you would do:
>
>   cpan install Digest::CPAN
>
> The first time you run cpan, it will need to configure your
> environment. You may have to use 'sudo cpan' for the first command.

The problem is that I don't know how to use this Digest thing, and I
don't know perl well enough to understand the description.  I was hoping
I could learn from some example that uses it.


-- 
"Object-oriented programming languages aren't completely convinced that
you should be allowed to do anything with functions."
http://www.joelonsoftware.com/items/2006/08/01.html

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to