From: Alex Bligh Date: Sat, 1 Sep 2012 18:59:00 +0000 (+0100) Subject: Add domd5sums.pl X-Git-Url: http://git.alex.org.uk Add domd5sums.pl --- diff --git a/domd5sums.pl b/domd5sums.pl new file mode 100755 index 0000000..3ad6175 --- /dev/null +++ b/domd5sums.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use File::stat; +use strict; +use warnings; + +use File::Basename; +use File::stat; +use MIME::Base64; +use File::Spec; +use File::Spec::Functions qw(rel2abs); + +my $datadir = dirname(rel2abs($0))."/"; + +sub getfile +{ + my $fn = $datadir.(shift @_); + $fn = File::Spec->rel2abs( readlink($fn) ) if (-l $fn); + return undef unless ( -f $fn); + return $fn; +} + +my $dir; +opendir($dir, $datadir); +my @links = grep { /^[^.]/ && -l $datadir.$_ } readdir($dir); +closedir($dir); + +foreach my $link (@links) { + my $target = getfile($link); + next unless ( defined ($target) && -f $target); + next unless ( $datadir eq dirname($target)."/" ); + system ("md5sum '$target' | tee '$target.md5sum'"); +}