in reply to How to get code of the calling function or object
In some cases you could use B::Deparse, e.g. via Data::Dumper:
use Data::Dumper; $Data::Dumper::Deparse = 1; sub foo { my ($foo) = @_; print "foo called with $foo\n"; print "going to call bar()...\n"; bar(); } sub bar { my $caller = (caller 1)[3]; print Dumper \&$caller; } foo(42);
$ ./895386.pl foo called with 42 going to call bar()... $VAR1 = sub { my($foo) = @_; print "foo called with $foo\n"; print "going to call bar()...\n"; bar(); };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get code of the calling function or object
by LanX (Saint) on Mar 25, 2011 at 14:28 UTC |