Nov 21, 2004 #1 arcnon Programmer Joined Aug 12, 2003 Messages 242 Location US whats wrong with this foreach my $key (key (@$allMyItems[$ITEM_array_number]->{main}{item_rules})){ print "$key\n"; }
whats wrong with this foreach my $key (key (@$allMyItems[$ITEM_array_number]->{main}{item_rules})){ print "$key\n"; }
Nov 21, 2004 #2 teriviret Programmer Joined Dec 12, 2003 Messages 288 Location US You forgot the 's' in 'keys'. Upvote 0 Downvote
Nov 21, 2004 #3 mikevh Programmer Joined Apr 23, 2001 Messages 1,033 Location US And keys requires a hash as its argument, which I don't see here. You're going to need to dereference the hash. I think you'd need something more like foreach my $key (keys %{$allMyItems->[$ITEM_array_number]->{main}{item_rules}}) { print "$key\n"; } though this is somewhat guesswork since I don't really know your data structure. Upvote 0 Downvote
And keys requires a hash as its argument, which I don't see here. You're going to need to dereference the hash. I think you'd need something more like foreach my $key (keys %{$allMyItems->[$ITEM_array_number]->{main}{item_rules}}) { print "$key\n"; } though this is somewhat guesswork since I don't really know your data structure.
Nov 22, 2004 Thread starter #4 arcnon Programmer Joined Aug 12, 2003 Messages 242 Location US in this case when I add items to the sub structure @$allMyItems[$ITEM_array_number]->{main}{item_rules}{newHash}= $hash_value Upvote 0 Downvote
in this case when I add items to the sub structure @$allMyItems[$ITEM_array_number]->{main}{item_rules}{newHash}= $hash_value