Class::MOP::Overload(3) User Contributed Perl Documentation Class::MOP::Overload(3)

# [SYNOPSIS](#SYNOPSIS)

```
    my $meta     = Class->meta;
    my $overload = $meta->get_overloaded_operator('+');
    if ( $overload->has_method_name ) {
        print 'Method for + is ', $overload->method_name, "\n";
    }
    else {
        print 'Overloading for + is implemented by ',
            $overload->coderef_name, " sub\n";
    }
```

# [DESCRIPTION](#DESCRIPTION)

This class provides meta information for overloading in classes and roles.

# [INHERITANCE](#INHERITANCE)

"Class::MOP::Overload" is a subclass of Class::MOP::Object.

# [METHODS](#METHODS)

## [Class::MOP::Overload-&gt;new(%options)](#Class::MOP::Overload)

This method creates a new "Class::MOP::Overload" object. It accepts a number of options:

- operator
  
  This is a string that matches an operator known by the overload module, such as "" or "+". This is required.
- method\_name
  
  The name of the method which implements the overloading. Note that this does not need to actually correspond to a real method, since it's okay to declare a not-yet-implemented overloading.
  
  Either this or the "coderef" option must be passed.
- method
  
  A Class::MOP::Method object for the method which implements the overloading.
  
  This is optional.
- coderef
  
  A coderef which implements the overloading.
  
  Either this or the "method\_name" option must be passed.
- coderef\_package
  
  The package where the coderef was defined.
  
  This is required if "coderef" is passed.
- coderef\_name
  
  The name of the coderef. This can be "\_\_ANON\_\_".
  
  This is required if "coderef" is passed.
- associated\_metaclass
  
  A Class::MOP::Module object for the associated class or role.
  
  This is optional.

## [$overload-&gt;operator](#$overload)

Returns the operator for this overload object.

## [$overload-&gt;method\_name](#$overload~2)

Returns the method name that implements overloading, if it has one.

## [$overload-&gt;has\_method\_name](#$overload~3)

Returns true if the object has a method name.

## [$overload-&gt;method](#$overload~4)

Returns the Class::MOP::Method that implements overloading, if it has one.

## [$overload-&gt;has\_method](#$overload~5)

Returns true if the object has a method.

## [$overload-&gt;coderef](#$overload~6)

Returns the coderef that implements overloading, if it has one.

## [$overload-&gt;has\_coderef](#$overload~7)

Returns true if the object has a coderef.

## [$overload-&gt;coderef\_package](#$overload~8)

Returns the package for the coderef that implements overloading, if it has one.

## [$overload-&gt;has\_coderef](#$overload~9)

Returns true if the object has a coderef package.

## [$overload-&gt;coderef\_name](#$overload~10)

Returns the sub name for the coderef that implements overloading, if it has one.

## [$overload-&gt;has\_coderef\_name](#$overload~11)

Returns true if the object has a coderef name.

## [$overload-&gt;is\_anonymous](#$overload~12)

Returns true if the overloading is implemented by an anonymous coderef.

## [$overload-&gt;associated\_metaclass](#$overload~13)

Returns the Class::MOP::Module (class or role) that is associated with the overload object.

## [$overload-&gt;clone](#$overload~14)

Clones the overloading object, setting "original\_overload" in the process.

## [$overload-&gt;original\_overload](#$overload~15)

For cloned objects, this returns the Class::MOP::Overload object from which they were cloned. This can be used to determine the source of an overloading in a class that came from a role, for example.

2026-08-29 perl v5.44.0

---

Document: Class::MOP::Overload(3pm) from perl-moose 2.4000-r4 (Chainguard OS)
Source: https://github.com/moose/Moose
