in reply to Capturing Results Of A System Command

If you are interested in generating checksums for files, the recommended practice these days is to use a digest function, and one that springs to mind is Digest::MD5. As this is a Perl module, it also means that you can calculate a checksum without relying on an external program. Here is a sample script to get you up and running:

use strict; use Digest::MD5 qw/md5_base64/; my $file = shift or die "No file specified on command-line.\n"; open IN, $file or die "Cannot open $file for input: $!\n"; my $digest = md5_base64(<IN>); close IN; print "Digest of $file is $digest\n";

Digest::MD5 has much stronger properties for guaranteeing that a given file has not been modified, and that two different files are indeed different, than the standard Unix checksum program.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'