Using Net::LDAP, I'm running into a problem trying to deal with multiple instances of an attribute. It appears that they get stored in a hash as an array of arrays; in the initial hash ($valref), I can dump the values like this:
@pktClassList = @$valref{packetclassifierlist}; print "class = "; foreach my $i (@pktClassList) { foreach my $j (@$i) { print "$j\n"; } }
Unfortunately I need to get @pktClassList to another sub as a member of a different hash. I'm assigning it to the hash in a switch statement like this:
... case /packetclassifierlist/ { $tlvHash{pktClassList} = "@pktClassLi +st" } ...
I then pass $tlvHash to my new sub as "newSub($tlv,%tlvHash);". In newSub I'm doing this:
... my ($tlv, %tlvHash) = @_; ... my $classArray = $tlvHash{pktClassList}; foreach my $i (@$classArray) { print "i = $i\n"; foreach my $j (@$i) { print "j = $j\n"; } }
I've tried various permutations of @, $, and @$ around classArray and tlvHash, but if the code executes at all, the best I get is "Can't use string ("ARRAY(0xa3f6e4)") as an ARRAY ref while "strict refs" in use...." I'm really trying to stick with packing this into %tlvHash instead of passing it as a separate arg, because multiple functions are calling newSub and they won't all have this attribute.
In reply to problems dereferencing an array of arrays as a hash value by jasonl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |