1Sub::Delete(3)        User Contributed Perl Documentation       Sub::Delete(3)
2
3
4

NAME

6       Sub::Delete - Perl module enabling one to delete subroutines
7

VERSION

9       1.00002
10

SYNOPSIS

12           use Sub::Delete;
13           sub foo {}
14           delete_sub 'foo';
15           eval 'foo();1' or die; # dies
16

DESCRIPTION

18       This module provides one function, "delete_sub", that deletes the
19       subroutine whose name is passed to it. (To load the module without
20       importing the function, write "use Sub::Delete();".)
21
22       This does more than simply undefine the subroutine in the manner of
23       "undef &foo", which leaves a stub that can trigger AUTOLOAD (and,
24       consequently, won't work for deleting methods).  The subroutine is
25       completely obliterated from the symbol table (though there may be
26       references to it elsewhere, including in compiled code).
27

PREREQUISITES

29       This module requires perl 5.8.3 or higher.
30

LIMITATIONS

32       If you take a reference to a glob containing a subroutine, and then
33       delete the subroutine with "delete_sub", you will find that the glob
34       you referenced still has a subroutine in it. This is because
35       "delete_sub" removes a glob, replaces it with another, and then copies
36       the contents of the old glob into the new one, except for the "CODE"
37       slot. (This is nearly impossible to fix without breaking
38       constant::lexical.)
39

BUGS

41       If you find any bugs, please report them to the author via e-mail.
42
44       Copyright (C) 2008-10 Father Chrysostomos (sprout at, um, cpan dot org)
45
46       This program is free software; you may redistribute or modify it (or
47       both) under the same terms as perl.
48

SEE ALSO

50       perltodo, which has "delete &sub" listed as a possible future feature
51
52       Symbol::Glob and Symbol::Util, both of which predate this module (but I
53       only discovered them recently), and which allow one to delete any
54       arbitrary slot from a glob. Neither of them takes perl 5.10 constants
55       into account, however. They also both differ from this module, in that
56       a subroutine referenced in compiled code can no longer be called if
57       deleted from its glob. The entire glob must be replaced (which this
58       module does).
59
60
61
62perl v5.30.0                      2019-07-26                    Sub::Delete(3)
Impressum