in reply to passing number of files in directory to subroutine
So, to keep things simple, save the file names as hash keys instead of array elements; then in the for loop that calls Calc(), step through the keys of one hash, skip the call if that key is missing from the other hash, otherwise call Calc on the two.
my %onedir = map { $_ => undef } grep /^\w/, readdir(DIR1); my %twodir = map { $_ => undef } grep /^\w/, readdir(DIR2); for my $file ( sort keys %onedir ) { next unless ( exists( %twodir{$file} )); Calc( "$dir1/$file", "$dir2/$file", $testfile ); }
|
|---|