Hello Monks!

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!


In reply to OO Design Question with Hashes of Arrays by ahackney

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.