As matija rightly points out, you'd want to initialize your TreeNodes hash value to an actual arrayref (which would be easy to create with the anonymous arrayref constructor []).
Update: here's an example if you want to go the explicit route:
my %hash = ( TreeNodes => [] ); push @{ $hash{TreeNodes} }, 1, 2; use Data::Dumper; print Dumper \%hash;
You do not even have to initialize the key, however. You can simply push into a previously non-existent key, and it will automatically be created and populated with an array reference. This is known as autovivification, and is made for situations like this.
Quick example:
my %hash; push @{ $hash{TreeNodes} }, 1, 2; use Data::Dumper; print Dumper \%hash;
Update: please see perlreftut and perlref for more information about references. (Re-reading your original question leads me to believe you might still be struggling with this topic. Hopefully I haven't assumed too much, but it's a common problem, so the docs might help.)
In reply to Re: array stored in anonymous hash
by revdiablo
in thread array stored in anonymous hash
by Kaluh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |