in reply to Getting the name of sub from sub reference

If you do use Devel::Peek; Dump $q[1];

You can see the sub name in the GVGV::GV field, so the data is still there, and an XS module could certainly retrieve it.

Maybe Sub::Identify does that, but I haven't tried if it works in this case.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Getting the name of sub from sub reference
by Anonymous Monk on Oct 14, 2010 at 18:40 UTC
    I have used the B module to display the glob's name which is what I think Sub::Identify uses:
    use warnings; use strict; use B qw(svref_2object); sub foo { print "I really do exist!\n"; } for my $coderef ( \&foo, \&bar ) { unless ( defined &$coderef ) { printf "could not call %s\n", svref_2object( $coderef )->GV->N +AME; } } # A symbol table entry is created for bar print "$::{ 'foo' }\n$::{ 'bar' }\n";