I have just started learning perl and OOPs concepts. I have a query regarding perl OOP concept.
Below is a standard piece of code showing class implementation. I understand with limited knowledge that $self is a reference to a hash, and this hash gets converted to an object after getting blessed. Blessing essentially means that the $self hash can now use any function in XYZ class for manipulation. Please correct me if I am wrong anywhere.
I have mostly come across examples where constructor function, such as "new" here contains a hash that gets blessed within the constructor. Many a times this hash may be nested to form a complex data structure. However, suppose instead of having one complex hash structures I choose to have two simple hash structures (say $self1 and $self2) . My question is, can we have two hashes (say $self1 and $self2) and both being blessed with the same class within the constructor. Is this allowed? If yes, then do $self1 and $self2 form two separate objects after being blessed. How then are $self1 and $self2 connected/related in anayway? Also, what are advantages of having a complex single hash vis a vis two simple hashes? I am actually confused. I guess I am missing something here.
Please advise.
Thanks,
package XYZ; sub new { my $class = shift; my $self = {}; return bless $self, $class; }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |