clegane has asked for the wisdom of the Perl Monks concerning the following question:
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"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to access array within hash
by NetWallah (Canon) on Jun 03, 2013 at 21:48 UTC | |
|
Re: Trying to access array within hash
by ig (Vicar) on Jun 04, 2013 at 07:11 UTC | |
|
Re: Trying to access array within hash
by BillKSmith (Monsignor) on Jun 04, 2013 at 12:37 UTC | |
by clegane (Novice) on Jun 04, 2013 at 13:47 UTC | |
by LanX (Saint) on Jun 04, 2013 at 14:16 UTC |