I want to add an optional method to a set of similar classes.
You could just import the method into the classes that need it.
For example, if you created a module like the following,
use strict; use warnings; package SpecialMethod; BEGIN { our @EXPORT = qw( special_method ); require Exporter; *import = \&Exporter::import; } use ... use ... sub special_method { ... } 1;
then just say use SpecialMethod; from the various classes into which you want to import the method.
Update: Oh wait. That doesn't address your main question at all. I don't think I can give a good answer without knowing more about what you are trying to accomplish, but it sounds like a perfectly reasonable use of can.
Update: Added missing *import = line.
In reply to Re: OO design: abstract class or can()?
by ikegami
in thread OO design: abstract class or can()?
by perrin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |