opendir THISDIR, "."; while ($file = readdir THISDIR) { if ($file =~ /csv$/i) { open(INPUT, "$file") or die "Could not open $file. \n"; @array = ; ($tab) = ($file =~ /.*\.(T\w+)\./); # Separate tab number from file name $data{$tab} = [@array]; close INPUT; } }