develooper Front page | perl.perl5.porters | Postings from March 2003

undefining an active subroutine

From:
Stas Bekman
Date:
March 17, 2003 23:24
Subject:
undefining an active subroutine
Message ID:
3E76C95D.1080404@stason.org
It's interesting that one can redefine an active subroutine, but can't 
undefine it. The following code:

   redefine();
   undefine();
   sub redefine { *main::redefine = sub {};}
   sub undefine { undef &main::undefine;   }

produces:

   Subroutine main::redefine redefined at /tmp/undef line 5.
   Can't undef active subroutine at /tmp/undef line 9.

How redefining of an active sub is different from undefining it? Won't it be 
possible to assign a NOP, so it'd emulate redefining to a NOP?

I've noticed this while trying to avoid the 'redefine' subroutine warnings on 
older perls where the pragma 'warnings' is not available. So I thought I could 
undef it first and then re-assign. But that didn't work ;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About