map { $_ => do { local ($/,*F); open F, "<$_" or die "Error reading '$_': $!"; }} glob('*') #or map{$_=>do{open my $fh,$_ or die"$_:$!";<$fh>}}glob('*') #### package MyPackage; sub make_hash { (local $/)=undef; my (@files,%hash); @files = @_; foreach my $file ( @files ) { open( my $fh, $file ) or next; $hash{$file} = <$file>; }; return \%hash; } __END__ #### 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)