Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Monday August 08, 2005
03:38 PM

How to keep a method private in an OO mix-in module.

[ #26187 ]
In CGI::Application-based applications, it's often handy to have a module that mixes-in methods into a primary module, which simply means that the methods are added using standard "has a" export/import techniques. That's what a number of the C::A plugins do.

There is a sticking point though. The mix-in may want to call an internal method, as:


However, the way the OO works, this method is expected in the package that has been mixed into, although you don't want to export it there.

Cees Hek pointed out a simple solution to this, which I managed to miss for several years:


Passing in $self like that keeps the method internal to the mix-in as desired.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.