Tip: given a coderef, show me where the code is
In Perl, sometimes you have a coderef, normally a callback, and you need to know where is that code located in your source.
This will do the trick:
sub _dude_wheres_my_coderef {
use Devel::Peek;
$code = \&$code; # guarantee a hard reference
my $gv = Devel::Peek::CvGV ($code) or return;
return *$gv{PACKAGE} . '::' . *$gv{NAME};
}
Taken from dump_vars.pl
. BTW, $name
also includes filename and line number.