If you make your selector like this:
Then you can call it with any object as $selector->($object) (parentheses - not curly braces to call it!) and it will either use the built-in eq or the overloaded version. As far as I understand you that is what you want which is why I probably don't understand you...my $selector = sub { $_[0] eq $whatever };
But as an aside you can get a reference to the overloading method with overload::Method, so if you really wanted you could to something like (for the "eq"-case)
my $selector = sub { my($obj)=@_; my $code_ref = overload::Method($obj, "eq"); if($code_ref) { # $obj overloads "eq" # call the overloading-implementation return $code_ref->($obj, $whatever); else { # no overloading -do something else return $obj eq $whatever; } };
In reply to Re: calling overloaded comparison operators as method calls?
by morgon
in thread calling overloaded comparison operators as method calls?
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |