use DB_FILE; my @files = glob ("*.db") #<== about 500 of these my @matrix; my %hash; my $key; my $i = 0; my $j = 0; while ($i<=$#files) { tie %hash, "DB_File", $files[$i], O_CREAT | O_RDWR, 0644 or die "Could not tie to $files[$i]: $!"; foreach $key (sort (keys (%hash))) { $matrix[$j]->[$i] = $hash{$key}; $j++; ##<== $j goes to about 6000 } $j = 0; $i++; }