in reply to Redefining Imported Subs: of scope and no
How do I dynamically redefine imported subroutines?
That's actually quite easy, but say is not being imported; it's not even a subroutine! say is an operator, and use feature 'say'; merely controls whether the compiler recognises it or not. (It always recognises CORE::say, though.)
Some operators can be overridden from within Perl by overriding GLOBAL::CORE::op, and some can't. The following checks whether say can be overridden this way:
>perl -E"say defined(prototype('CORE::say')) ?'yes':'no'" no
Its funky syntax doesn't permit it.
say say LIST say FILEHANDLE LIST say BLOCK LIST
It could be done using a CallChecker, but that involves dropping to C/XS.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Redefining Imported Subs: of scope and no
by LanX (Saint) on Feb 11, 2013 at 10:08 UTC | |
by ikegami (Patriarch) on Feb 11, 2013 at 21:34 UTC |