If you try to undef the CODE slot of a glob, it only halfway works. ref(*foo{CODE}) will still show that it is a code reference, and UNIVERSAL::can still shows that it is a code reference.
-------- #! /usr/bin/perl -l print "Originally foo() is a " . ref(*foo{CODE}); print "Initializing foo()"; *foo = sub {print "hello"}; print "foo() is now a " . ref(*foo{CODE}); print "According to can, foo is " . main->can("foo"); print "Calling foo()"; foo(); print "Undefining foo()"; $x = *foo; undef &$x; print "foo() is now a " . ref(*foo{CODE}); print "According to can, foo is " . main->can("foo"); print "Calling foo()"; foo(); __END__ Originally foo() is a Initializing foo() foo() is now a CODE According to can, foo is CODE(0x8175b24) Calling foo() hello Undefining foo() foo() is now a CODE According to can, foo is CODE(0x8175b24) Calling foo() Not a CODE reference at - line 17 --------
The way that this comes into play in the case that Module1 attempts to undefine subroutines that have been defined, but when Module2 tries to check whether they are there it is told that they are, with disasterous results. what is should I do ?
2006-10-07 Unapproved by planetscape once evidence of habitual plagiarism uncovered.
In reply to undefing *foo{CODE} does not fully work by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |