in reply to Is there exist a module to provide access to a file via hashes using TIE ?
Note that the sub also returns a bool response, so you can tell if it successfully loaded the file or not.%magichash; &magic(\%magichash, '/path/to/file/fn'); print $magichash{'/path/to/file/fn'}; sub magic { my $handle; if (open($handle, $_[1])) { $_[0]->{$_[1]} = join('', <$handle>); close($handle); return 1; } }
|
|---|