Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
As far as I know, we can only do it for CODE references:
# obtain CODEref name use B; sub coderef2name { my ($coderef) = @_; return unless UNIVERSAL::isa($coderef, "CODE"); my $obj = B::svref_2object($coderef); return $obj->GV->STASH->NAME . "::" . $obj->GV->NAME; }

Update: Changed to use GV->STASH->NAME instead.

Note that:
> perl -MDevel::Peek -e '$var = 123; Dump \$var; sub my_sub {}; Dump \ +&my_sub' SV = RV(0x8073260) at 0x804cc28 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x8065648 SV = IV(0x8068920) at 0x8065648 REFCNT = 2 FLAGS = (IOK,pIOK) IV = 123 SV = RV(0x8073260) at 0x804cc28 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x8064b34 SV = PVCV(0x8061538) at 0x8064b34 REFCNT = 2 FLAGS = () IV = 0 NV = 0 COMP_STASH = 0x804cb50 "main" START = 0x806d6a8 ===> 1053 ROOT = 0x806fa68 XSUB = 0x0 XSUBANY = 0 GVGV::GV = 0x8065684 "main" :: "my_sub" FILE = "-e" DEPTH = 0 FLAGS = 0x0 OUTSIDE_SEQ = 91 PADLIST = 0x8064b04 PADNAME = 0x804cce8(0x8088758) PAD = 0x8065678(0x805e5b0) OUTSIDE = 0x804cd78 (MAIN)

In reply to Re: How to get the name from a reference by repellent
in thread How to get the name from a reference by michi

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the questions are moot...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (9)
    As of 2018-04-25 13:26 GMT
    Find Nodes?
      Voting Booth?