Hi Lee,

some comments on your code:

On Wed, 12 Jun 2013 11:28:34 +0200
lee <l...@yun.yagibdah.de> wrote:

> 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

Is your Perl at /bin? Shouldn't it be in /usr/bin?

> 
> use strict;
> use warnings;
> 
> use Digest::SHA

You're missing a ";" at the end.

> 
> our $fh;

Why the our?

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

$ctx and $arg were not declared so «strict» will complain.

> 
> open $fh, "testfile";

1. You shouldn't pre-declare $fh .

2. You should use «use autodie;».

> $ctx->addfile( $fh);

You can also add a filename using "->addfile ()"

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

This code won't compile.

Perhaps learn Perl properly using some of the resources here:

* http://perl-begin.org/ (my own link).

* http://perl-tutorial.org/

* http://perl-begin.org/tutorials/bad-elements/ (also my link).

Regards,

        Shlomi Fish
> 
> ... 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.
> 
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"The Human Hacking Field Guide" - http://shlom.in/hhfg

Q: I’ll be about 6.5 milliard Terran years next September.
    — http://www.shlomifish.org/humour/Star-Trek/We-the-Living-Dead/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

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