If you can provide the package name as a parameter then you can:
use strict; use warnings; package Foo; sub Bar { } package main; sub test { my ($package, $function_ref) = @_; no strict; for my $key (keys %{"${package}::"}) { my $ref = ${"${package}::"}{$key}; if (defined $ref && \&$ref eq $function_ref) { print "${package}::$key\n"; } } } test ('Foo', \&Foo::Bar);
Prints:
Foo::Bar
In reply to Re: find out method name from the reference
by GrandFather
in thread find out method name from the reference
by perlfan99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |