In Perl, how can I check from which module a given function was imported?

Viewed 3909

I have a code which calls the function. But I don't know the module this function belongs to. I need it to modify this function.

How can I check it?

4 Answers

You can pass to Sub::Identify::sub_fullname any subroutine reference and it will show you the module where this sub was defined:

use Sub::Identify qw/sub_fullname/;
sub foo {
    print sub_fullname( \&foo );  # main::foo
    print sub_fullname( sub{} );  # main::__ANON__
}

foo();

For details see Sub::Identify

Related