The brackets [] create a reference to an anonymous array. With an array inside the brackets like [ @pktClassList ], the contents of the @pktClassList array are copied into the new anonymous array.
There is a different way to get the same effect, but which avoids the second copy. If the @pktClassList array is a local variable in a subroutine, which gets used only once before going out of scope, then you could have used the @pktClassList array directly like this:
case /packetclassifierlist/ { $tlvHash{pktClassList} = \@pktClassLi +st }
The key is the scope of the original @pktClassList array - when the variable goes out of scope, it becomes an anonymous array by virtue of being referenced by the %tlvHash hash. Quite unlike the C language.
See perlref for more info on references. Anonymous arrays are addressed early in the document.
In reply to Re^3: problems dereferencing an array of arrays as a hash value
by gmargo
in thread problems dereferencing an array of arrays as a hash value
by jasonl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |