http://www.perlmonks.org?node_id=964158


in reply to Re: Why won't a hash in a hash work as a hash reference to create an object?
in thread Why won't a hash in a hash work as a hash reference to create an object?

sundialsvc4, first thank you for the respect, courtesy, and politeness. You did not have to be any of those things, so I appreciate it. Perl is my first and only programming language, and I am learning programming concepts as I go. I had perltoot up in my browser as I was trying to write that object above, however the example in "Constructors and Instance Methods" did not show how a predefined data source, in my case an HoH, could be connected to an object. Even after reading perltoot, I made my best guess on how to reference a hash in a hash in an object even though my guess was wrong. Had perltoot started with package People; instead of package Person;, I may have gotten the hang of objects sooner.

perltoot starts with a table for one person we know nothing about (in this case Jason), instead of starting with a table for several people for whom we have already gathered data (not only Jason, but his peers Norbert, Rhys, and Phineas too). Had perltoot started with the following and created package people; first, it would have been more enlightening to me.

my $records = [ { name => "Jason", age => 23, peers => [ "Norbert", "Rhys", "Phineas"], }, { name => "Norbert", age => 24, peers => [ "Jason", "Phineas", "Michael"], }, { name => "Rhys", age => 22, peers => [ "Norbert", "Jason", "Robert"], }, { name => "Phineas", age => 23, peers => [ "Norbert", "Jason", "Alexandra"], }, ];

I could possibly take an example object which had an A(ref)oH and converted it to an HoH in my objects. I was having a hard time with perltoot starting in what I consider the end.

Have a cookie and a very nice day!
Lady Aleena