What is the $param returned for each 'type' key after the subroutine
&return_param_name? I'd suggest you sprinkle some print statements around as follows and show what
&return_param_name looks like,
my $value = $q->{'content'};
my $param = $q->{'type'};
print $param,"$/"; #<------------------Here
#$value =~ s/^\s+|\s*$//g;
$param = &return_param_name($param);
print $param,"$/"; #<--------------------Here
push @{$qryhash{$param}}, $value;
Since your problem lays in converting an AoH to a HoA by iterating over the AoH, using the Dumped output you provided it is possible to iterate as follows:
#!/usr/local/bin/perl
#title "Problem iterating AoH"
use strict;
use warnings;
my @queries = (
{
'content'=>'Blocking',
'type' => 'blocking'
},
{
'content'=>'p01',
'type'=>'Priority'
}
);
my %hash;
for my $reference (@queries){
push @{$hash{$reference->{'type'}}},$reference->{'content'};
}
use Data::Dumper;
print Dumper(\@queries),"\n";
print Dumper(\%hash);
OUTPUT:
$VAR1 = [
{
'content' => 'Blocking',
'type' => 'blocking'
},
{
'content' => 'p01',
'type' => 'Priority'
}
];
$VAR1 = {
'blocking' => [
'Blocking'
],
'Priority' => [
'p01'
]
};
Excellence is an Endeavor of Persistence.
Chance Favors a Prepared Mind.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.