Nov 21, 2004 #1 arcnon Programmer Aug 12, 2003 242 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 Dec 12, 2003 288 US You forgot the 's' in 'keys'. Upvote 0 Downvote
Nov 21, 2004 #3 mikevh Programmer Apr 23, 2001 1,033 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 Aug 12, 2003 242 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