Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Referencing a hash of hashes

by imp (Priest)
on Aug 18, 2006 at 15:20 UTC ( #568185=note: print w/replies, xml ) Need Help??


in reply to Re^2: Referencing a hash of hashes
in thread Referencing a hash of hashes

You can get this information from B::Deparse.
sub a { print "foo\n"; } use B::Deparse; my $deparser = B::Deparse->new('-p'); print $deparser->coderef2text(\&a);
Update - You can get the source of the subroutine with B::Deparse I should have said. Perhaps you meant the name of the subroutine.

Replies are listed 'Best First'.
Re^4: Referencing a hash of hashes
by imp (Priest) on Aug 18, 2006 at 15:35 UTC
    Please note that the code in this post is not the recommended method. It makes uses of B, which is the perl compiler backend. As such it is a little too magical to be used in production code.

    That said, it is interesting to know how to do this, and can be useful at times. This is one way to get the name of a subroutine.

    sub a { print "foo\n"; } use B; # Fetch the internal object for this coderef my $obj = B::svref_2object(\&a); # Fetch the glob for that object my $gv = B::CV::GV($obj); print $gv->NAME;
Re^4: Referencing a hash of hashes
by Ronnie (Scribe) on Aug 21, 2006 at 08:38 UTC
    My update WAS misleading - it's only the name of the subsoutine that I need.
    Cheers, Ronnie

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2020-08-05 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (37 votes). Check out past polls.

    Notices?