Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by LanX (Saint)
on Oct 26, 2017 at 14:27 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-16 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found