in reply to overload =~ operator

I know this doesn't answer your question, but a more concrete example showing what form you envision class B taking would be helpful to anyone who might answer.

Replies are listed 'Best First'.
Re^2: overload =~ operator
by dk (Chaplain) on Sep 27, 2006 at 13:09 UTC
    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.