in reply to Struggling with complex data structures and doing useful operations on their elements and populating from arrays

Update: Added results.
# How to loop through the first layer: What is in @info? print "\$info:\n"; foreach my $info_item (@info) { print " []='$info_item'\n"; }

Results:

D:\PerlMonks>lists2.pl $info: []='Mary,Owens,cat,white' []='Bill,Thompson,(cat,dog),(white,black)' []='Bill,Thompson,(hamster,cat),(black,brown)' []='Bill,Smith,(goldfish,dog,turtle),(yellow,spotted,green)'
  • Comment on Re: Struggling with complex data structures and doing useful operations on their elements and populating from arrays
  • Select or Download Code

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:10 UTC

    each scalar $infoi are each intended as a row in @info

      You may name the loop control scalar anything you like.

      You asked how to loop. I am showing you some basic techniques, and some common problems with the basic techniques, so you grasp the whole problem and, hopefully, see a path to the whole solution.

      Okay, it looks like nobody else will answer your question, and you won't answer mine.

      In the interest of helping a future Hash/Array Perl newcomer who might want to see the problem from the same angle you are seeing it, here's the solution I would have worked you toward.

      You can ask about anything here, but I'm not likely to check this thread anymore.

      Hope this helps.

      And here's the subroutine I used to try and make the operation a little more clear:

      I would also point out that in my copy, I wrote a series of unit tests into this routine, because it was just complex enough to warrant that level of care -- and those tests caught a bug I had introduced into the code. Root cause? Sheer arrogance. Good engineering practices protect us from many things, but most of all from ourselves.