in reply to Use cases for 'sub Pckg::func { }' ?
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(\@_) }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use cases for 'sub Pckg::func { }' ?
by LanX (Saint) on Jul 31, 2020 at 14:32 UTC | |
by ikegami (Patriarch) on Aug 01, 2020 at 06:38 UTC | |
by LanX (Saint) on Aug 01, 2020 at 08:38 UTC | |
by ikegami (Patriarch) on Aug 01, 2020 at 16:28 UTC |