Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-23 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found