in reply to building a hash with filname and itscontents
The extra braces are important. Otherwise what you've got is a single-element slice of the hash referenced by the scalar $spr_hash. Enabling use strict would have given you a hint that something was wrong by pointing out that you were referencing this undeclared scalar variable. Truthfully, though, you can write those two lines more simply as@{$spr_hash{$file_name}}
and put the file contents right in the anonymous array. No need to initialize it with a blank array first.$spr_hash{$file_name} = [<FH>];
|
|---|