I have the following hash of arrrays of arrays in perl
$VAR1 = {
'A' => [
[
'1',
'PRESENT_1',
'ABSENT_2',
],
[
'2',
'PRESENT_1',
'ABSENT_2',
]
],
'B' => [
[
'5',
'PRESENT_1',
'ABSENT_2',
],
[
'6',
'PRESENT_1',
'ABSENT_2',
],
[
'7',
'ABSENT_1',
'PRESENT_2',
]
]
};
I want to access the first element from each small array and print it to the console.
So the output should look like this
EL 1
EL 2
EL 5
EL 6
EL 7
I'm having difficulties with looping through the arrays and dereferencing. I've started like this, but that's clearly not the correct way
my %hash = %{ $VAR1 };
for my $key (sort keys %hash) {
for my $arr1 (@{ $hash{$key} }){
for my $arr2 (@{ $arr1}) {
print "EL ", @{ $arr2 }[0], "\n";
}
}
}