develooper Front page | perl.perl5.porters | Postings from August 2001

How to redefine sub that has prototypes without warning at runtime?

Thread Next
From:
Neulinger, Nathan
Date:
August 17, 2001 14:04
Subject:
How to redefine sub that has prototypes without warning at runtime?
Message ID:
F349BC4F5799D411ACE100D0B706B3BB7690E6@umr-mail03.cc.umr.edu

The following snippet generates the following warning:

---
sub foo () { print "foo"; }
undef &foo;
eval 'sub foo () { print "bar"; }';
---

	Prototype mismatch: sub main::foo vs () at (eval 1) line 1.

If you put the undef inside the eval, it works, but that is not convenient
for this case.

Any suggestions? Seems like undef is getting rid of the subroutine
definition, but not the prototypes. 

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@umr.edu
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216

Thread Next


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