: method attribute description . A routine that is marked this way will not trigger the "Ambiguous call resolved as CORE ::% s" warning.
From ysth comment :
A warning occurs when sub has the same name as the built-in, and it is called without and not as a method call; perl uses the built-in instead, but gives a warning. Method: quiets warns a warning because it clearly indicates that sub was never intended to be called as a non-method in any case.
Update
This code simply calls the bar method when foo is called:
sub foo : method {
More details:
: method - indicates that the routine referenced is a method. A routine that is marked this way will not trigger the "Ambiguous call resolved as CORE ::% s" warning.shift - gets the first parameter from @_ , which will be $self->bar(@_) - call the same bar class method with all other parameters
You can read this as:
sub foo : method { my ($self) = shift @_; return $self->bar(@_); }
Ivan Nevostruev
source share