--------------8<-------------- sub md5files { use File::Basename; my $dir = $_[0]; # where the files are (must be a direct path from root /) my $what = $_[1] || '*'; # what files, default = '*' (all files) my $md5file = "$dir/checksums.md5"; my %hash_md5; my @t = split(/ /, $what); open (MD5OUT, '>', $md5file ) or die "Err: $!"; foreach my $f (@t) { foreach my $file2md5 (<$dir/$f>) { next if "$file2md5" eq "$md5file"; my $md5 = &md5calc($file2md5); if($md5 ne "") { $file2md5 =~ s/$dir\///; print MD5OUT $md5 . " " . $file2md5 . "\n"; $hash_md5{$md5} = $file2md5; } else { return ""; } } } close MD5OUT; return %hash_md5; } --------------8<--------------