Not necessarily a class, just overloading a binary operator like '+' or '*' would be fine. For example, it's easy to write
use overload '+' => sub { Class->new($_[1])-> add($_[0]) };
but impossible to
use overload '=~' => sub { Class->new($_[1])-> match($_[0]) };
... and of course, I want my own implementation of match() here, unrelated to perl5 regexes. |