G'day ahackney,

Welcome to the monastery.

"... making the contents of the hash an array is a mystery to me."

A hash contains pairs of keys and values. While the contents of a hash could be considered as an array with an even number of elements, I'm guessing that's not really what you're driving at. Take a look at perlintro - Perl variable types for an overview and follow the links therein for more detailed discussion.

"I am trying to make the following hash an attribute of the above class."

Given the example data you've shown, I imagine you want to end up with something along these lines:

my $self = { ... aclsMissingFromMaster => { list1 => [1, 2, 3, 4], list2 => [5, 6, 7, 8], ... }, };

Take a look at Perl Data Structures Cook Book - HASHES OF ARRAYS to understand this data structure and how it can be created, accessed and manipulated.

You haven't provided sufficient information to advise whether a separate class for ACLs would be appropriate. If this is the only place you're handling ACLs, then maybe not; however, if you'll be working with ACLs in other classes (or as stand-alone objects), then it probably would be a good idea.

As you appear to be at the design (or, at least, very early development) stage, I'd recommend you consider Moose (or one of its relatives, e.g. Mouse, Moo) rather than coding your constructors from scratch and dealing with all the issues that arise from that course of action. The Moose DESCRIPTION starts off:

Moose is an extension of the Perl 5 object system.

The main goal of Moose is to make Perl 5 Object Oriented programming easier, more consistent, and less tedious. With Moose you can think more about what you want to do and less about the mechanics of OOP.

-- Ken


In reply to Re: OO Design Question with Hashes of Arrays by kcott
in thread 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.