$VAR = "old VAR"; sub func {return ("old func()")} sub show {printf "VAR='%s', func()='%s'\n", $VAR, func()} sub redefine { eval 'sub func {return ("new func()")}'; local ($VAR) = "new VAR"; show(); } show(); redefine(); show();