I am trying to create a multidimensional hash with its keys as an array so that the same keys can store multiple values, and is not overridden.
Below is the code snippet:
my %hashR;
my @RelDiv = qw(15.4 dev ques 15.4 dev ques2 15.4 dev2 ques1 15.4 dev2 ques2
15.2 dev3 ques2);
while (my $RName = shift @RelDiv) {
my $ProStr = shift @RelDiv;
push @{$hashR{$RName}}, $ProStr;
my $BName = shift @RelDiv ; ## Working file till here (tried printing the values)
push @{$hashR{$RName}{$ProStr}}, $BName; ###### Error on this line
}
The structure I want is as follows:
{
'15.4' => {
'dev' => [
'ques',
'ques2'
]
'dev2' => [
'ques1',
'ques2'
]
},
'15.2' => {
'dev3' => [
'ques2'
]
}
};
But, I am getting an error "Not a HASH reference at file1.pl line". Can anyone please help in resolving the error?
Thanks