What are the use cases of that pattern?
The pattern you are observing is that the package directive controls the package in which code is compiled. sub X::foo { pp(\@_) } is simply not an exception to that. Effort to provide a special behaviour for sub X::foo { pp(\@_) } was not spent.
Put differently,
is short forsub X::foo { pp(\@_) }
which is effectively what happens every time you import a symbol from a module (e.g. use X qw( foo );).BEGIN { *X::foo = sub { pp(\@_) }; }
In reply to Re: Use cases for 'sub Pckg::func { }' ?
by ikegami
in thread Use cases for 'sub Pckg::func { }' ?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |