Endless has asked for the wisdom of the Perl Monks concerning the following question:
So, yeah, I'm confusing myself. But here's the situation: Scanning for terms through multiple files, I want to keep track of each place a term is found in addition to the number of times the term shows up. So, I have hash of hashes with a scalar $count and an array $location. At least, that's what I want to have. So, how can I make this work? Yes, before you ask, at this point I am just throwing around @{$} and whatever other symbols I can come up with. Teach me, oh wise ones!
my %hoh; my @arr = ('first', 'second', 'third'); push (@{$hoh{'word'}}{'array'}, @arr); #no good $hoh{'word'}{'count'} += 1; $hoh{'word'}{'count'} += 1; say "The count of 'word' is ", $hoh{'word'}{'count'}; say "The array of 'word' is ", @{$hoh{'word'}}{'array'}; # still no go +od.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Push to an array in a hash of hashes
by kennethk (Abbot) on Aug 07, 2013 at 21:44 UTC | |
by BillKSmith (Monsignor) on Aug 08, 2013 at 01:45 UTC |