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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.