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'


In reply to Re: Log's and MD5 Hashes -- FINALLY DONE by Anonymous Monk
in thread Log's and MD5 Hashes by satanklawz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.