in reply to Tie, DBM's, HoH and Sparse Keys

try creating a tied hash in the subroutine, then set the hashref passed in to that hash:
sub { my ($hashref, $key) = @_; my %hash; tie %hash, ....; $hashref->{$key} = \%hash; }
Actually, though, I'd think about using a database, starting with maybe DBD::RAM, then on to a indexable database.