Also, the keys doc. The argument for keys must be a hash and has a % sigil.
The exists doc tells you its argument is a hash element which will have a $ sigil. You need to read your error messagefor my $key (keys %hash){ #... } for my $key (keys %{$hashref}){ # dereferencing a hash #... }
asexists argument is not a HASH or ARRAY element
exists argument is neither a HASH element nor an ARRAY element
An observation.if (exists $hash{some_key}){ #.. } if (exists $hashref->{some_key}){ # dereferencing a hash element using + an arrow #.. }
...what about %{$$coordinates{$group}{$id}{$stage}{"coords"}}...The %{...} does the dereferencing, there's no need for the extra $ in $$. I prefer the -> for dereferencing (many monks don't) but it is often unnecessary (as in this case).
Have a look at the tutorial linked to above. I look at it at least once a week. :-)
update: When I'm have a fight with a convoluted data structure I try out the syntax on a simplified version and get that working first. And while you're doing that don't forget the mighty Data::Dumper. Good luck!
In reply to Re^2: Test if a subhash in a referenced hash exists
by wfsp
in thread Test if a subhash in a referenced hash exists
by Henri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |