opendir( DIR1, $dir1 ) or die("Error opening: $dir1"); my @files1 = sort grep {-f "$dir1/$_"} readdir(DIR1);