On Wed, Oct 22, 2003 at 08:22:47PM -0500, Wiggins d'Anconia wrote: > Gupta, Sharad wrote: >> Now from this coderef ($x) i want to know its fully qualified name >> which would be somthing like Bar::Foo. Is there a way to do that.??. > > Where do you want to know it? Presumably if you have set it then you > should know it already [ snip ] > > Within foo, there is __PACKAGE__ which will give you Bar...
Given only the coderef, you can use something like this #!/usr/bin/perl -l sub fq_name { require B; my $ref = shift or return; my $glob = B::svref_2object($ref)->GV; join "::", $glob->STASH->NAME, $glob->SAFENAME; } print fq_name($_) for \&foo, sub {}; But normally you don't need to know the name of a code reference in order to use it. (And anonymous coderefs don't really have a name.) -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]