Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: how to find the module of a specific *method*?

by LanX (Sage)
on Oct 26, 2017 at 14:27 UTC ( #1202076=note: print w/replies, xml ) Need Help??


in reply to how to find the module of a specific function?

> the module, in which the login function appears?

Don't know what you mean with "appears" ..

  1. If you want to know which modules actually use this method (!) , ...

    ... you could use caller inside the method to report the locations at runtime.

    (not sure if applying B::Xref helps with methods)

  2. If you want to know where the method was defined ...

    ... you can might be able to use ->can to get the function's reference and use introspection with B to find the origin. (untested, will update code)

Update
  • my $c_ref = $obj->can("method_name") will return the reference of the method
  • my ($file, $line) = get_code_location($c_ref) in Sub::Identify allows you to retrieve the original source location

the latter can be done without extra module using some half cryptic B code, but I'm reluctant digging it out.

IIRC an example can be found in the O'Reilly book "Perl Hacks" or google is your friend.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-05-23 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?