Hi ahackney,
While, I advise that you take vantage of the wisdom and words of kcott, I will say it's not bad to 'eat' on the boilerplate of perl OO intrinsic design.
..I am trying to make the following hash an attribute of the above class...
You could write subroutine, to 'set' and 'get', the value of the hash attribute like this:
{
package My::Sys;
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;
}
sub set_acls{
my $self = shift;
my $cot = 0;
$self->{aclsMissingFromMaster}{"list ".++$cot} = $_ for @_;
}
sub get_acls{
my $self = shift;
return $self->{aclsMissingFromMaster};
}
}
use Data::Dumper;
my $sys = My::Sys->new();
my @arr = ([1..4],[5..8],);
# set the attribute
$sys->set_acls(@arr);
{
local $Data::Dumper::Sortkeys = 1;
# get your values here
print Dumper $sys->get_acls();
}
..you get...
$VAR1 = {
'list 1' => [
1,
2,
3,
4
],
'list 2' => [
5,
6,
7,
8
]
};
Just an example for you to see...
You might want to check some other documentation like
perlobj,
perlootut.
-
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.