SHA question
Dermot
paikkos at googlemail.com
Wed Jan 13 12:44:47 GMT 2010
Hi,
I have a lots of PDFs that I need to catalogue and I want to ensure
the uniqueness of each PDF. At LWP, Jonathan Rockway mentioned
something similar with SHA1 and binary files. Am I right in thinking
that the code below is only taking the SHA on the name of the file and
if I want to ensure uniqueness of the content I need to do something
similar but as a file blob?
Thanx,
Dp.
use strict;
use warnings;
use Digest::SHA qw(sha256_hex);
use FindBin qw($Bin);
my $top = "$Bin/pdfs";
opendir my $dir, "$top" or die "Can't open $top: $!\n";
my @files = grep { /pdf$/ } readdir $dir;
foreach my $n (@files) {
if (-e "$top/$n" }) ) {
my $digest = sha256_hex($n);
print "$n\t$digest\t:". length($digest)."\n";
}
else {
print "Can't find $top/$n\n";
}
}
PS: I don't see many perl questions here, am I breaking a convention?
More information about the london.pm
mailing list