use strict; use warnings; my ($dir1, $dir2, $testfile) = @ARGV; opendir DIR1, $dir1 or die "Can't open directory $dir1: $!\n"; opendir DIR2, $dir2 or die "Can't open directory $dir2: $!\n"; my @onedir = readdir(DIR1); my @twodir = readdir(DIR2); closedir DIR1; closedir DIR2; for my $onefile (@onedir) { my $twofile = shift @twodir; next if $onefile =~ /^\./; $onefile = "$dir1\\$onefile"; $twofile = "$dir2\\$twofile"; Calc($onefile, $twofile, $testfile); } sub Calc { my ($onefile, $twofile, $testfile) = @_; print "$onefile, $twofile, $testfile\n"; }