Whilst developing a bespoke module to determine the provenance of a class method (local or inherited), this (simplified) test harness code ...
package simple_obj; use Class::Flyweight::Lite::Core qw/attrib/; sub add_attrib { my $self = shift } } sub get_addr { \&add_attrib } package main; use warnings; use strict; use Test::More; diag 'simple_obj->get_addr(): ' . simple_obj->get_addr(); diag 'simple_obj->can(qw/get_addr/): ' . simple_obj->can(qw/get_addr/) +; diag '\&simple_obj::get_addr: ' . \&simple_obj::get_addr;
generates the following unexpected results:
. . # simple_obj->get_addr(): CODE(0x8e9da2c) # simple_obj->can(qw/get_addr/): CODE(0x8ff8bd8) # \&simple_obj::get_addr: CODE(0x8ff8bd8) . .
I say unexpected because, since the same sub is the subject of the various operations, my expectation was that the returned address/ref. should be the same in all cases - but it self-evidently isn't.

So, is it me and my understanding of the perldoc for UNIVERSAL - specifically '...returns a reference to the sub.' ?

By way of an in-situ update, I've now found Class::Inspector - which does everything I wanted my module to do ... thanx be to CPAN - for all the joy, wonders & labour saving :-)

UPDATE: Thanx to dsheroh for pointing out the problem that was so obvious to all but me in Re: How can the same sub have 2 different references.

A user level that continues to overstate my experience :-))

In reply to RESOLVED: How can the same sub have 2 different references by Bloodnok

Title:
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, details, 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, summary, 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.