chinaxing has asked for the wisdom of the Perl Monks concerning the following question:
The next::method has a similar problems because it uses the package of its
caller to figure out what class to look at. If you define a method in Donkey from
another package, next::method will break:
package main; *Donkey::sound = sub { (shift)–>next::method(@_) };
The anonymous subroutine shows up in the stack with as _ _ANON_ _, so next::method doesn’t know which package it is in. You can use the Sub::Name CPAN module to make it work out, though:
use Sub::Name qw(subname); *Donkey::sound = subname 'Donkey::sound' => sub { (shift)–>next::method(@_) };
I am very inquisitive how Sub::Name module complete this work ? let the anonymous subroutine's caller not be __ANON__
very thanks your help :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how Sub::Name set anonymous subroutine 's caller to NOT __ANON__ ?
by tobyink (Canon) on Jul 15, 2013 at 09:40 UTC | |
|
Re: how Sub::Name set anonymous subroutine 's caller to NOT __ANON__ ? (__PACKAGE__)
by Anonymous Monk on Jul 15, 2013 at 09:56 UTC |