Is there a module that lobotomizes subroutines?

brian_d_foy on 2009-02-18T20:59:56

Is there already a module that will turn a list of subroutines into no-ops? I'm doing this to disable features in production code, not testing, and only because other work-arounds are intractable. It's monkeypatching to give a class a lobotomy.

I know about Curtis's Sub::Override, so I might just write a wrapper around that for an interface that looks something like:

use Sub::Nerf;

nerf( $return_value, @list_of_subs ); # all subs just return $return_value

unnerf( @list_of_subs ); # back to where we started



Hook::LexWrap

bart on 2009-02-18T22:01:07

In Hook::LexWrap, you can make the pre-hook sub return prematurely, instead of going on to running the real, original sub. You do that by assigning a return value to the extra parameter that it gets. See Short-circuiting and long-circuiting return values

Sub::Delete

srezic on 2009-02-22T11:16:17

I use Sub::Delete to remove a method definition in libwww-perl, to workaround the bug mentioned here: https://rt.cpan.org/Ticket/Display.html?id=22839