root/trunk/tools/md5sum.pl

Revision 202, 500 bytes (checked in by depesz, 3 years ago)

md5sum is not always available on all platforms, and it's really useful. Here is portable, perl-based implementation.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Carp;
5 use English qw( -no_match_vars );
6 use Digest::MD5;
7
8 die "You have to provide filenames to calculate md5sum of.\n" if 0 == scalar @ARGV;
9
10 for my $filename ( @ARGV ) {
11     if ( open my $fh, '<', $filename ) {
12         my $md5 = Digest::MD5->new();
13         $md5->addfile( $fh );
14         printf "%-32s  %s\n", $md5->hexdigest, $filename;
15         close $fh;
16     }
17     else {
18         carp "Cannot open $filename for reading: $OS_ERROR\n";
19     }
20 }
21
22 exit;
23
Note: See TracBrowser for help on using the browser.