"Object variables in perl seem to be stored as hash elements..."

Only if the object in question is a blessed hash reference. A Perl object is simply a blessed referent - you can also bless arrays, subroutines, regexes, and even scalars. See Blessables -- What Can You Make Into Objects? for more on that.

Back to your array ref - meditate on the following code: a class is defined with a single attribute (an array ref) and two accessor methods - one that returns a copy of the array ref and one that returns a copy of the array. Various methods of trying to change the attribute are attempted, but the only one that works is the last one, which assigns a new array ref explicitly.
use strict; my (@array,$array); my $foo = foo->new(); # won't change @array = $foo->get_array; @array = ('a'..'f'); print join(',',$foo->get_array),"\n"; # won't change $array = $foo->get_array_ref; $array = [('a'..'f')]; print join(',',$foo->get_array),"\n"; # won't change $array = $foo->{_array}; $array = [('a'..'f')]; print join(',',$foo->get_array),"\n"; # will change $foo->{_array} = [('a'..'f')]; print join(',',$foo->get_array),"\n"; package foo; use strict; sub new { bless { _array => [(0..9)] }, shift } sub get_array { @{shift->{_array}} } sub get_array_ref { shift->{_array} }
And please note that i 'abbreviated' this object's methods only for the sake of brevity. Please don't use this style in production code. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Storing arrays as object variables by jeffa
in thread Storing arrays as object variables by Basilides

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.