I am working with legacy code and must require .pl file that defines sub foo . My problem is that in my main:: namespace there is already another sub foo , which is called later in that part of the program that I am not currently working with.
The required file is defined by sub foo {} because, obviously, it does not want foo events to occur where they are usually called. In my case, this is bad.
I tried playing with *foo glob:
*old_foo = *foo; require 'foo_killer.pl'; *foo = *old_foo;
Of course, this did not work, since I created only an alias (as shown on page 133 of the Perl Master Wizard), and therefore *old_foo will now point to the "empty" routine.
Is there a way to somehow copy something in *foo{CODE} to another place instead of overlaying it? Or maybe there is a different approach to solving this issue?
source share