achang27 achang27 - 4 months ago 15
Perl Question

Perl AUTOLOAD - get name of unknown method without class name

I am writing an

AUTOLOAD
method for a Perl class.

I can get the name of the unknown method with

$name = $ExampleClass::AUTOLOAD;


However this gets me the full identifier:
ExampleClass::unknownmethodname
.

I just need
unknownmethodname
. How can I only get that portion of the name?

Answer Source
( my $method_name = our $AUTOLOAD ) =~ s/^.*:://s;

or

my $method_name = our $AUTOLOAD =~ s/^.*:://sr;    # 5.14+