Help for this page

Select Code to Download


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