in reply to OO - best way to have protected methods

Have a look at Attribute::Protected. You can just go
package SomeClass; use Attribute::Protected; sub foo : Public { } sub _bar : Private { } sub _baz : Protected { }
Likewise Class::Declare::Attribues does something similar

Replies are listed 'Best First'.
Re^2: OO - best way to have protected methods
by gargle (Chaplain) on Aug 18, 2005 at 05:34 UTC
    How do these two compare to my solution performance wise? The syntax is nice of course but it looks to me as if there are more method calls involved behind the scenes? Am I right?

    (It's been 3 years ago since I last did anything serious, >50 lines, in perl... So I am a bit rusty. Java does that to you, you know ;)
      Well, you'd best benchmark it. If you're calling methods in a tight loop it might be a problem, but if you look at the code - say of Attribute::Protected - you're simply calling one other explict method and one anonymous sub for an attribute that you assign to your methods. That slight penalty is offset by the readability conferred IMHO