in reply to Log's and MD5 Hashes -- FINALLY DONE
in thread Log's and MD5 Hashes

Firstly, you really should be posting comments and follow-up code under the same thread rather than starting new threads for each new discussion on the thread.

With the code here ...

while (<CONFIGFILE>) { chomp; $file = $_; open(FILE, $file) or die "Can't open $file"; binmode(FILE); $md5 = Digest::MD5->new; while (<FILE>) { $md5->add($_); } close(FILE); print RESULTS $md5->b64digest, " ", $file, "\n"; #print $md5->b64digest, "\n"; $a=$a+1; }

... you could write this a lot more neatly making use of the addfile and reset methods of Digest::MD5 rather than iterating through each line of the file and constructing a new Digest::MD5 object with each loop. eg.

my $md5 = Digest::MD5->new; while (<CONFIGFILE>) { chomp; $md5->reset; { local *FILE; open (FILE, $_) || warn $!; binmode FILE; $md5->addfile(*FILE); close FILE; } # stuff with $md5 digest methods }

Now, its beyond this segment of code that the purpose of some of the code flow became a little hazy to me - The second while loop could me written differently with a direct comparison between scalar contexts of the arrays without the use of the superfluous counter variables - Also too, the use of $a and $b as variable names is not a good choice given the magic role which these play within Perl. eg. sort.

Anyhow, while I would write the code differently, if it does what you need, good luck and well done on your efforts thus far.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'