[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



sub AUTOLOAD {
}


sub new {
  my $type = shift;
  my $class = ref $type || $type;
  my @ARA = {};
  my $ref = \@ARA;

  bless $ref, $class;
  return $ref;
}

sub get_num {
  my $self = shift;
  my @W = $self;
  return $#W;

}

sub append {
  my $self = shift;
  push @{$self}, shift;
}


return 1;

# vi: set ts=2 sw=2: #


The append does not work.

On Sun, 2004-08-01 at 18:48, Fletch wrote:
> >>>>> "Chris" == Chris Fowler <cfowler at outpostsentinel.com> writes:
> 
>     Chris> I'm trying to figure a way to implement private members in
>     Chris> perl objects but all the text I'm reading has me confused
> 
> The followup you posted (using a closure as your instance) is one way;
> using something like Tie::SecureHash rather than a plain hashref is
> another.  In general Perl relies on convention rather than enforcement
> in matters of encapsulation.  You don't muck around with an object's
> insides unless you do so according to a published interface; if you
> decide to do so you do it with the knowledge that any breakage caused
> by doing so is your fault.


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00047" href="msg00047.html">[ale] Private members in perl</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00037" href="msg00037.html">[ale] Private members in perl</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Chris Fowler)</li></ul></li>
<li><strong><a name="00043" href="msg00043.html">[ale] Private members in perl</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00044.html">[ale] OT: Well  it is going to hit the list sooner or later.</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00046.html">[ale] OT: Well  it is going to hit the list sooner or later.</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00043.html">[ale] Private members in perl</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00047.html">[ale] Private members in perl</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00045"><strong>Date</strong></a></li>
<li><a href="threads.html#00045"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>