# 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)'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Struggling with complex data structures and doing useful operations on their elements and populating from arrays
by hiyall (Acolyte) on Mar 12, 2015 at 14:33 UTC | |
by marinersk (Priest) on Mar 12, 2015 at 15:15 UTC |