Re: implementing "protected" in OO perl

From: Shawn Corey (shawn.corey_at_sympatico.ca)
Date: 01/16/05


Date: Sun, 16 Jan 2005 15:58:18 -0500

SNeelakantan_C@zaplet.com wrote:
> Is there a way of making a certain variable 'protected' so that only
> methods in derived classes may access it? I would prefer a mechanism
> that doesn't wrap the variable in a method call since performance would
> slow down by an order of magnitude.
>
> -Shanker
>
Short answer no and yes. See perldoc -f my

'my' limits the variable's scope to the file (among other things) so if
your object is in a single file, this will work.

    --- Shawn


Loading