Hey there. I have a hash that's sort of 3-dimensional. Each hash value is itself an array of strings and arrays. The hash %policies has been populated with this line:
$policies{$ruleNum} = [ $ruleName, $srcZone, [ @srcList ], $dstZone, [ @dstList ], [ @svcList ], $ruleAction ];I'm trying to get into the embedded arrays with the following code, but the print command is giving array references. What am I doing wrong? Thank you!!!
sub get_address_policies { my $targetAddr = shift; my $targetType = shift; my $targetRole = shift; my @polMembers; foreach my $policy (keys %policies) { (lc($targetRole) eq "source") ? (@polMembers = $policies{$poli +cy}[2]) : (@polMembers = $policies{$policy}[4]); foreach my $polMember ( @polMembers ) { print "$polMember\n"; } } }
In reply to Trying to access array within hash by clegane
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |