llancet has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone! My problem is same as the title, like this:
my $ref = \&foo::bar::func; my $str = some_magic($ref); # got "foo::bar::func"
As ref() gives 'CODE', and "$ref" gives 'CODExxxxx', how to achieve such magic?

Replies are listed 'Best First'.
Re: How to know function name and package from its ref?
by chromatic (Archbishop) on Dec 17, 2009 at 07:23 UTC
Re: How to know function name and package from its ref?
by Anonymous Monk on Dec 17, 2009 at 07:21 UTC
Re: How to know function name and package from its ref?
by afoken (Chancellor) on Dec 18, 2009 at 00:42 UTC

    In 99.9% of all cases, you don't need this information. This is what the various discussions linked above clearly show. What is your real problem?

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      I have to store subref in a thread::shared data structure. It seems not allowed. So I decide to save function's name instead. It seems works well.
        I have to store subref in a thread::shared data structure. It seems not allowed.

        What makes you think that? Got an electric shock as soon as you typed the code and another one when you ran it?

        Come on, you are not new here. Show us the relevant parts of your code and any error messages you get from running it! Random guessing won't help you.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)