in reply to Re^4: Checking MD5 of files in directory with corresponding MD5 file type
in thread Checking MD5 of files in directory with corresponding MD5 file type

hold its content in memory

Assuming the *.md5files contain just the value (single line ?) then consider reading them all first and use a hash to store the results for comparison later, for example

#!perl # test.pl use strict; use warnings; use Cwd; use Digest::MD5; use Data::Dump 'pp'; my $sourcedirectory = cwd(); # '//path/to/directory' # create test file with md5 value open my $io_handle,'<','test.pl' or die "$!"; my $md5 = Digest::MD5->new; $md5->addfile($io_handle); close $io_handle; open OUT,'>','test.md5' or die "$!"; print OUT $md5->hexdigest; close OUT; # read md5 values into a hash my $md5values = get_md5values($sourcedirectory); pp $md5values; sub get_md5values { my $sourcefiles = shift; opendir(DIR, $sourcefiles) or die "Can't open directory, $!"; my @md5_files = grep /\.md5$/,readdir(DIR); closedir(DIR); my %md5 = (); for my $filename (@md5_files){ my $count = 0; open MD5,'<',$filename or die "$!"; while (<MD5>){ chomp; $md5{$filename} .= $_; ++$count; } close MD5; print "$count lines read from $filename\n"; } return \%md5; }
poj