Here's the code:
in_some_sub{ open(THISFILE,'< $file') or warn "ERROR: Can't open $outfile!\n"; binmode(THISFILE); while(read(THISFILE,$part,1)){ $md5->add($part); } $data = $md5->hexdigest; return unless ($data); remove_dupes($data,$file); }
(assume a "my ($md5)=new Digest::MD5" earlier and $file is the name returned by "File::Find::name"..)
I've tried using $md5->addfile(*THISFILE), tried using a FileHandle object using $md5->add($part) and $md5->addfile($fh)...

I'm using a hash to keep track of the digests and original file..remove_dupes() notifies of duplicate digests indicating duplicate files and allows you to choose to delete one of them...this code always reports the same:
Fingerprinting files with MD5SUM... Press enter to continue... ERROR: Can't open md5sums.txt! d41d8cd98f00b204e9800998ecf8427e ./Thumbs.db ERROR: Can't open md5sums.txt! ---Duplicates found--- Remove which file: 1."./Thumbs.db" , 2."./ABNC001.JPG" ,or 3. Ignore and do not delete either file. (1/2/3)?:3 Ignoring... d41d8cd98f00b204e9800998ecf8427e ./ABNC001.JPG ERROR: Can't open md5sums.txt! ---Duplicates found--- Remove which file: 1."./Thumbs.db" , 2."./vincent05.jpg" ,or 3. Ignore and do not delete either file. (1/2/3)?:3 Ignoring... d41d8cd98f00b204e9800998ecf8427e ./vincent05.jpg ERROR: Can't open md5sums.txt! ---Duplicates found--- Remove which file: 1."./Thumbs.db" , 2."./tux_trek.gif" ,or 3. Ignore and do not delete either file. (1/2/3)?:
BTW this works (correctly) if i use "$data=`md5sum -b $file`;" instead...:
C:\WINDOWS\Profiles\madams\My Documents\My Pictures>md5sum -b Thumbs.d +b ABNC001.JPG vincent05.jpg tux_trek.gif 0b32237bb069cff23325ef2ea6c386ca *Thumbs.db 06b0c8cc903f49d131b27621389fb57d *ABNC001.JPG 032c0f9c5b5e9afe63936417037d8f4a *vincent05.jpg 8294e114b207d343000f74c72840a1ed *tux_trek.gif
note the code as is reports a bogus digest for Thumbs.db..
What went wrong?
_________________
madams@scc.net
(__) (\/) /-------\/ / | 666 || * ||----||

In reply to Why the same hex digest? by Madams

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.