- or download this
package My::SuperNumber;
use overload (
...
return $swap ? -$result : $result;
},
);
- or download this
use overload (
# this is the cryptic name of the "numification" operator
...
return $self->as_number;
},
);
- or download this
use overload (
# this is the cryptic name of the "stringification" operator
...
RETVAL = my_stringify(left);
OUTPUT:
RETVAL
- or download this
sub as_string {
my($obj) = @_;
...
unless overload::Method($obj, '""');
return "$obj";
}
- or download this
sub as_string {
my($obj) = @_;
...
# RIGHT
return $method->($obj, undef, 0);
}