Lots of threads about iterating over an array of hashes, which I do daily. However now I want to iterate over an AoH in and AoH. I'm interested in the array "chapters" because I want to add a hash to each array element of that inner array:
$criteria = [
{
'title' => 'Focus on Learning',
'chapters' => [
{
'content_id' => '182',
'criteria_id' => '1',
'title' => 'Focus on Learning',
},
{
'content_id' => '185',
'criteria_id' => '1',
'title' => 'Teachers Role',
},
{
'content_id' => '184',
'criteria_id' => '1',
'title' => 'Parents in Class',
},
{
'content_id' => '183',
'criteria_id' => '1',
'title' => 'Students at Home',
}
],
'tot_chaps' => '4'
},
This, in theory, is want I want to do.
for my $i ( 0 .. $#$criteria ) {
for my $j ( 0 .. $#$criteria->[$i]{'chapters'}) {
print $criteria->[$i]{'chapters'}->[$j]{'title'}."\n";
}
}
print $criteria->[$i]{'chapters'}->[1]{'title'}."\n"; -> Teachers Role