Thanks.
I can see two/three use patters now
- your demo: ad hoc definition of small but related OOP classes in a horizontal way (contrary to "vertical" inheritance)
- keeping the class' namespace clean of imported subs (kind of namespace::clean but right from the beginning)
the latter even
- on a method basis
- without need of explicit import
{
package Subs::I::Want;
sub Target::Class::method {
my ($self) = shift;
$self->method2();
sub_I_want()
}
}
{
package Other::Subs::I::Want;
sub Target::Class::method2 {
other_sub_I_want()
}
}
hence
- Target::Class->method() or ->method2() work
- Target::Class->sub_i_want() or ->other_sub_I_want() won't work
GREAT, learned something new! :)