in reply to Re^2: How to redefine a modules private function?
in thread How to redefine a modules private function?
1. my code was wrong in that part
package ALIEN; no warnings "redefine"; sub DOMAIN_PORT() { 666 }
it's better written as
no warnings "redefine"; *ALIEN::DOMAIN_PORT = sub() { 666 };
2. But this creates a weird error
Attempt to free unreferenced scalar: SV 0x6917d8, Perl interpreter: 0x767b98 at d:/tmp/pm/patch_constant.pl line 41.
Which is most likely explained by %SIG
__DIE__/__WARN__ handlers are very special in one respect: they may be called to report (probable) errors found by the parser. In such a case the parser may be in inconsistent state, so any attempt to evaluate Perl code from such a handler will probably result in a segfault. This means that warnings or errors that result from parsing Perl should be used with extreme caution, like this:
nice idea, but no luck :/
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: How to redefine a modules private function?
by LanX (Saint) on Mar 09, 2022 at 13:30 UTC | |
by LanX (Saint) on Mar 09, 2022 at 13:46 UTC |