in reply to Re: Reblessing (was: OO Perl: calling a constructor within a class)
in thread OO Perl: calling a constructor within a class
Were you thinking something like this?
Objects can always can, but a special can can can the usual can. But to see it's a special can you can:(Sorry)But you can't catch the man who replaced the default can:$check_that_can_with = UNIVERSAL::can($obj,'can') ne \&UNIVERSAL::can;So can that man before he cans your can!my $can = \&UNIVERSAL::can; local $^W = 0; *UNIVERSAL::can = sub { $_[1] eq 'can' ? \&UNIVERSAL::can : &$can; };
In Section
Seekers of Perl Wisdom