generates the following unexpected results: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;
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.. . # simple_obj->get_addr(): CODE(0x8e9da2c) # simple_obj->can(qw/get_addr/): CODE(0x8ff8bd8) # \&simple_obj::get_addr: CODE(0x8ff8bd8) . .
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.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |