I am stuck in what seems to me a simple conceptual problem. After carefully searching for similar problems on the Internet and overflowing the stack, I couldn't find something like this, so I thought I might ask you.
I am creating a hash hash structure that is deeply nested. Depth can be 10-20 times. For the sake of this problem, I list only to the depth.
I cannot recursively go through the hash image of the sample below in Perl. I also included my code.
This gives me the following error:
It is not possible to use string ("1") as a HASH ref, while "strong links" are used when
It’s just so clear: my hash has certain keys with a value of 1. I cannot escape them.
$VAR1 = { 'Eukaryota' => { 'Rhodophyta' => {'count' => 5}, 'Alveolata' => {'count' => 16}, 'stramenopiles' => {'count' => 57}, 'count' => 155, 'Glaucocystophyceae' => {'count' => 1}, 'Cryptophyta' => {'count' => 18}, 'Malawimonadidae' => {'count' => 1}, 'Viridiplantae' => {'count' => 57}, }, 'Bacteria' => { 'Cyanobacteria' => {'count' => 1}, 'Actinobacteria' => {'count' => 4}, 'count' => 33, 'Proteobacteria' => {'count' => 25}, 'Deinococcus-Thermus' => {'count' => 2}, 'Firmicutes' => {'count' => 1}, }, };
Code to recursively pass this hash:
sub analyse_contig_tree_recursively { my $TAXA_TREE = shift @_; my $contig_hash = shift @_; foreach (keys %{$TAXA_TREE}) { print "$_ \n"; analyse_contig_tree_recursively($TAXA_LEVEL->{$_}, $contig_hash); } }