Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Identify the package a subroutine is being called from

by pc88mxer (Vicar)
on Jun 06, 2008 at 17:37 UTC ( #690713=note: print w/ replies, xml ) Need Help??


in reply to Re: Identify the package a subroutine is being called from
in thread Identify the package a subroutine is being called from

The debugger certain can get the calling arguments, even if @_ has been modified (i.e. shifted).

Here's a solution using Devel::StackTrace:

use Devel::StackTrace; sub calling_object { my $t = Devel::StackTrace->new; my $f; $f = $t->next_frame for (1..4); ($f->args)[0] } sub e { my $x = shift; print "x = $x\n"; d('humma'); } sub d { print "I was called by object ", calling_object(), "\n"; } e('a', 'b', 'c');


Comment on Re^2: Identify the package a subroutine is being called from
Select or Download Code
Re^3: Identify the package a subroutine is being called from
by jettero (Monsignor) on Jun 06, 2008 at 17:50 UTC
    Holy crap. That's exactly what I wanted. I should have asked years ago.

    -Paul

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-04-23 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls