i am processing this structure to build HoA (%qryhash). I have listed the code below. in the foreach loop is executed only once. I need the following$VAR1 = \[ { 'content' => 'Blocking', 'type' => 'Blocking' }, { 'content' => 'P01', 'type' => 'Priority' } ];
But i am getting onlyprint Dumper(\%qryhash); $VAR1 = { 'Blocking' => [ 'Blocking' ], 'Priority' => [ 'P01' ] };
Here is the code snippet.print Dumper(\%qryhash); $VAR1 = { 'Blocking' => [ 'Blocking' ] };
Can anyone please find out the mistake in my code and help me out?sub extract_table_queries{ my $configitem = $_[0]; my @assigneearray = (); my %qryhash; print ref $configitem->{'config'}; if (ref $configitem->{'config'} eq 'ARRAY'){ @queries = @{$configitem->{'config'}}; $i = 0; $count = @queries; foreach $q (@{$configitem->{'config'}}){ my $value = $q->{'content'}; my $param = $q->{'type'}; #$value =~ s/^\s+|\s*$//g; $param = &return_param_name($param); push @{$qryhash{$param}}, $value; if (lc $param eq lc $configitem->{rollup}){ push @rolluplist,$value; } my $tmp = sprintf("%-15s",$param); print "------>$tmp: $value\n"; } print Dumper(\%qryhash); print Dumper(\$configitem->{'config'}); exit; return(\%qryhash); } }
In reply to Problem iterating AoH by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |