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

You define a hash %pets but never use it, nor does your desired output suggest a printed hash. Also, Bill Thompson has two cats, one white and one brown, but your output has only one.

It will help us help you if you can be more consistent in your problem definition.

Dum Spiro Spero
  • Comment on Re: Struggling with complex data structures and doing useful operations on their elements and populating from arrays

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

    Apologies

    The %pets should be built from a loop thru the @info. The desired structure of the %pets is {scalar}{scalar}{array}{array} with no duplicated element in the {array} fields. The serves to summarize the data with no duplicates. The desired output would then to list the contents of each $pets{first}{last}{species}{color} on its own line, the combination {first}{last} is unique for the hash. The 2 arrays should be populated such that duplicate elements are discarded. This desired summarization is reflected in the desired output example. I have struggled with this little task for a couple of days now - my expertise is not quite sufficient enough yet ... but soon

      FYI, about the uniqueness in the array and sorting algorithm, you can use a prolog-like system to build your %pets. The trick is to negate clauses which are true so that your system inferes faster. It's a bit over the top but here's the stuff on CPAN : https://metacpan.org/search?q=prolog
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 15:11 UTC

    Thank you for your comment. I have modified the sample code and explanation - I hope this is more clear