in reply to Finding the size of a nested hash in a HoH
while( my($key, $val) = each %{$rHoH_ProteinFamilies}){ my $size = (keys %{$val->{proteinfamily});
I suppose a more devious method to find the size of a hash is to use the equivalence between arrays and hashes:
my $size = @{[%$val->{proteinfamily}]}/2;
In other words you can think of hashes as arrays sliced up into sequential pairs, p1 & p2, where p1 = the key and p2 = the value. Hence the hash size will always be 1/2 the length of the array representation.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Finding the size of a nested hash in a HoH
by BrowserUk (Patriarch) on Nov 10, 2011 at 16:21 UTC | |
by aaron_baugher (Curate) on Nov 10, 2011 at 16:55 UTC | |
by BrowserUk (Patriarch) on Nov 10, 2011 at 17:16 UTC | |
by remiah (Hermit) on Nov 11, 2011 at 07:51 UTC | |
by BrowserUk (Patriarch) on Nov 11, 2011 at 08:24 UTC | |
| |
by Anonymous Monk on Nov 11, 2011 at 08:52 UTC | |
| |
by aaron_baugher (Curate) on Nov 11, 2011 at 14:59 UTC |