md5.pl



NAME

md5.pl <filename>


DESCRIPTION

Comput MD5 digest for <filename>.

This is a good replacement for 'md5sum'.


COPYRIGHT

Copyright 2010 Etienne LEMEE <coding AT etilem DOT net>

This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


#!/usr/bin/perl -w

use strict;
use Digest::MD5;

@ARGV > 0 or die << "USAGE";

usage: $0 <filename>

comput MD5 digest for <filename>
USAGE

my $file = shift;
my $ctx = new Digest::MD5;

open my $FILE, '<', $file or die $!;

binmode $FILE;

$ctx->addfile(*$FILE);

printf "%s  %s\n", $ctx->hexdigest, $file;