Hey guys, thought i would ask my question here, i am new to perl and moving rather quickly in it, trying to write POOP code which seems to be more of a hustle in Perl than any other non scripting language i ve used so far.

Lets take the following example:

package Farm; use strict; use warnings; sub new { my $className = shift; my $self = { $farmName,"", "farmMamals",(), "farmBirds",() }; bless $self,$className; return $self; } sub addFarmBirds { my self =shift; my tempBirds=[] ; # right way of initialising an array ?? if (@_){ @tempBirds=@_}; #now for the part i dont understand $self->{farmBirds} = @tempBirds; return } }

Here my intention is to declare a hash of variables that belong to the specific object (forgive my poor terminology, still trying to get the gribs of it). From what i understand farmBirds is declared as an array (not a reference to one).
If i now call myFarm->addFarmBirds(@someFarmBirdsArray) will that array's items be placed inside the farmBirds array internal to the object "myFarm"? Or are the variables i declared in the class Farm stored as references?
will something like my @birds = $self->{farmBirds}; successfully make a copy of the farmBirds array in the @birds array? It doesnt not appear to be the case, any ideas on how i can make that happen?


In reply to Help!!!! POOP is confusing me! by bittis

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.