foreach $filename (glob('*', '.*')) { open(DF, $filename) or die(); @{$hash{$filename}} = ; close(DF); } #the snippet i mentioned would have had the contents in @{$hash{$filename}}, #but you would have had to reassemble that back into a single string, if that is what you needed)