in reply to Calc md5 for file by drag and drop (Windows)

Nice! But...

use Digest::MD5::File qw(file_md5);

Ok, but then you're using Digest::MD5 instead, which indeed is loaded by Digest::MD5::File. You may just either use the former since it's a core module now or take advantage of the latter:

my $myfile = shift; my $md5 = new Digest::MD5; $md5->addpath($myfile); my $digest = $md5->hexdigest; Win32::Clipboard::Set ($digest);

I would just either

Win32::Clipboard::Set Digest::MD5->new->addpath(shift)->hexdigest;

or

Win32::Clipboard::Set file_md5 shift;

in the two respective cases hinted above.

Oh, and I wouldn't print $digest; since we're putting that info in the clipboard anyway, but I would use wperl.exe instead. Of course an alternative would be a minimal GUI (e.g. Tk) showing the computed checksum, possibly along with a button to copy to the clipboard or compare with a value previously stored into it. However this would loose the fascinating simplicity/minimality of your solution...

Replies are listed 'Best First'.
Re^2: Calc md5 for file by drag and drop (Windows)
by GrandFather (Saint) on Oct 18, 2005 at 20:04 UTC

    This was something I wipped up quickly at work when I needed to calculate a digest and knew that I would need to do it again occassionally. I posted it here having come in at the tail end of a CB converstaion and thought it might help the person asking the the MD5 related question so it got posted in a hurry too.

    I'm pleased to see it's been so popular and I appreciate the feedback. I'll put together a more fully featured version at some point adding in your suggestions and fizbin's ideas and the ability to calc the MD5s for a folder full of files too. The code won't be quite so compact, but usage can remain similar.


    Perl is Huffman encoded by design.