First of all, I'm not sure what Perl's equivalent of Java's bean properties are called (any ideas?). I am using methods of a certain class to store data - eg
sub entity2 { $_[0]->{entity2}=$_[1] if defined $_[1]; $_[0]->{entity2 +} } sub IxnCount { $_[0]->{IxnCount}=$_[1] if defined $_[1]; $_[0]->{IxnCo +unt} }
However the above can only get / set / store scalars. To have object properties which can store arrays, I have been doing the following:
sub synsatMaxScore1 { my ($self, @pmIDs) = @_; if (@pmIDs) { my $ref = \@pmIDs; $self->{synsatMaxScore1} = $ref; } return $self->{synsatMaxScore1}; }
To set the property, it's  $object->synsatMaxScore1(@array). However it seems that the data can ultimately only be stored as a reference to an array, and also when getting the property, at the moment you then have to derefererence the array:
my $arrayref = $object->synsatMaxScore1; my @array = @$arrayref;
Is there any way of changing the method so that it can return arrays too? I guess this is something to do with the way Perl internally handles Object Oriented modules... Thanks in advance.

In reply to Bean properties... by buz260

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.