David Christensen <dpchr...@holgerdanske.com> writes:

> On 06/11/13 21:44, lee wrote:
>> ... what I don't understand is what
>> the most efficient way would be to create a sha-2 sum for a file.
>
> Have you considered Digest?
>
>     http://perldoc.perl.org/Digest.html

Yes, I've been looking at descriptions like that and I don't know perl
well enough to understand them.  I wanted to learn perl for ages and
never got around to it.  Now I'm finding it extremely useful, and I'm
learning it the wrong way by not starting at the beginning ...

I've come up with this for a test:


#!/bin/perl

use strict;
use warnings;

use Digest::SHA

our $fh;

$ctx = Digest->new(SHA-256 => $arg);

open $fh, "testfile";
$ctx->addfile( $fh);

print "hash: " . $ctx->b64digest . "\n";


... and that says:


,----
| "" is not exported by the Digest::SHA module
| Can't continue after import errors at sha.pl line 8.
| BEGIN failed--compilation aborted at sha.pl line 8.
`----


As you can see, I don't don't know what I'm doing here.
"$ctx = Digest->new(SHA-256 => $arg);" is probably not right, but I
don't know what I'm supposed to put for $arg.  The error message doesn't
make any sense to me, either, line 8 is "our $fh;".

This is why I was looking for an example so I can see how these things
are being used.


-- 
"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