MuttleyDiXiE
MIS
Hi,
I'm trying to create a three-dimensional hash but I can't seem to get it right. In the code beneath I push data into my Hash of Hash of Hash = $HoHoH. This seems to work fine.
foreach my $line (@aonly){
if($line =~ m/^(.*)("\/)(\d+)(\/)(.*)(\/)(.*)(\/)(.*)(")/){
# do away with double lines
if($data[$id-1] eq "$3 $9"){
}else{
$id = push @data,"$3 $9";
push @{$HoHoH{$3}->{$5}}, $9;
}
}
}
Now next I'm trying to loop over the three-dimensional hash and return all values inside.
for my $custnumber (keys %HoHoH){
print "$custnumber\n";
for $nodename (keys %{ $HoHoH{$custnumber} } ){
print "$nodename\n";
for $filename (keys %{$HoHoH{$custnumber}{$nodename}}){
print "$filename\n";
}
}
print "\n\n";
}
This is the part I can't get to work. When I run the script it tells me "Can't coerce array into hash at test.pl line 69" which referres to this line "for $filename (keys %{$HoHoH{$custnumber}{$nodename}}){".
Can anyone please help me understand how to work with this kind of data structure.
Best regards
DiXiE
I'm trying to create a three-dimensional hash but I can't seem to get it right. In the code beneath I push data into my Hash of Hash of Hash = $HoHoH. This seems to work fine.
foreach my $line (@aonly){
if($line =~ m/^(.*)("\/)(\d+)(\/)(.*)(\/)(.*)(\/)(.*)(")/){
# do away with double lines
if($data[$id-1] eq "$3 $9"){
}else{
$id = push @data,"$3 $9";
push @{$HoHoH{$3}->{$5}}, $9;
}
}
}
Now next I'm trying to loop over the three-dimensional hash and return all values inside.
for my $custnumber (keys %HoHoH){
print "$custnumber\n";
for $nodename (keys %{ $HoHoH{$custnumber} } ){
print "$nodename\n";
for $filename (keys %{$HoHoH{$custnumber}{$nodename}}){
print "$filename\n";
}
}
print "\n\n";
}
This is the part I can't get to work. When I run the script it tells me "Can't coerce array into hash at test.pl line 69" which referres to this line "for $filename (keys %{$HoHoH{$custnumber}{$nodename}}){".
Can anyone please help me understand how to work with this kind of data structure.
Best regards
DiXiE