in reply to OO - best way to have protected methods

I think the second example in your post is the usual behavior in any OO language. I would advice you to use croak() or confess() - from Carp - in place of die().


Igor S. Lopes - izut
surrender to perl. your code, your rules.
  • Comment on Re: OO - best way to have protected methods

Replies are listed 'Best First'.
Re^2: OO - best way to have protected methods
by gargle (Chaplain) on Aug 17, 2005 at 14:37 UTC
    Obrigado, thanks you,

    I'll put your advice to good use. It's in line with what I do for protected methods:
    # protected method printMe, silly example actually sub printMe { my $self = shift; caller(0)->isa(__PACKAGE__) || confess "cannot call protected +method\n"; # do something silly for now print $self->account . " " . $self->name . " " . $self->balanc +e . "\n"; }