See
perldsc, note how
$sec->{content} is not a hash reference but an array reference, and don't use
$_ so much.
for my $sec ( @{ $data->{sections} } ) {
print "Section: ", $sec->{title}, "\n";
for my $img ( @{ $sec->{images} } ) {
print "Image: ", $img, "\n";
}
print "Content Text: ", $sec->{content}[0]{text}//'(undef)' ,"\n";
for my $elem ( @{ $sec->{content}[0]{elements} } ) {
print "Element Text: ", $elem->{text}, "\n";
}
}
Output:
Section: 10-minute Turkey
Content Text: (undef)
Section: Description
Content Text: Makes 4 servings.
Section: Ingredients
Content Text: (undef)
Element Text: abc
Element Text: efg
Element Text: hij
Section: Directions
Content Text: (undef)
Element Text: tuv
Element Text: wxy
Element Text: z12