ahackney has asked for the wisdom of the Perl Monks concerning the following question:
I'm new to OO in Perl. I have a class that I have created. In this class, I need an attribute that is a hash whose members contain an array.
I have gotten the hash to work, but making the contents of the hash an array is a mystery to me.
I'm wondering if I need another class that this class will have as an attribute?
sub new { my $class = shift; my $self = { coreID => 0, isBpMaskError => 0, isVrrpErrors => 0, isSymPriorityErrors => 0, isSslProfileErrors => 0, isGlobalPortErrors => 0, isVipsinVipGroupsErrors => 0, isVipGroupErrors => 0, isSnatIpErrors => 0, isCodeVersionErrors => 0, aclsMissingFromMaster => {}, }; bless $self, $class; return $self; }
I want the aclsMissingFromMaster hash to contain an array. Should I just make a class ACLS with attributes being arrays and make that class object an attribute of this class? Or is there a way to make the above class contain a hash containing arrays.
eg: I am trying to make the following hash an attribute of the above class.
%hash1{'list1'}-> [1,2,3,4] %hash1{'list2'}-> [4,5,6,7] ...
Thanks for your wisdom!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO Design Question with Hashes of Arrays
by kcott (Archbishop) on Jun 26, 2013 at 02:38 UTC | |
|
Re: OO Design Question with Hashes of Arrays
by Anonymous Monk on Jun 26, 2013 at 04:04 UTC | |
by ahackney (Initiate) on Jun 26, 2013 at 13:23 UTC | |
by AnomalousMonk (Archbishop) on Jun 26, 2013 at 17:09 UTC | |
|
Re: OO Design Question with Hashes of Arrays
by Loops (Curate) on Jun 26, 2013 at 01:57 UTC |