# How to loop through the second layer: What is in each element of @i +nfo? print "\$info:\n"; foreach my $info_item (@info) { #print " []='$info_item'\n"; # Let's try a simple split command: my @info_fields = split /\,/, $info_item; print "\$info_field:\n"; foreach my $info_field (@info_fields) { print " []='$info_field'\n"; } }
Results show us that this simple approach is not sufficient to match the complexity of the data structure:
D:\PerlMonks>lists3.pl $info: $info_field: []='Mary' []='Owens' []='cat' []='white' $info_field: []='Bill' []='Thompson' []='(cat' []='dog)' []='(white' []='black)' $info_field: []='Bill' []='Thompson' []='(hamster' []='cat)' []='(black' []='brown)' $info_field: []='Bill' []='Smith' []='(goldfish' []='dog' []='turtle)' []='(yellow' []='spotted' []='green)'
In reply to Re: Struggling with complex data structures and doing useful operations on their elements and populating from arrays
by marinersk
in thread Struggling with complex data structures and doing useful operations on their elements and populating from arrays
by hiyall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |