in reply to Re: Re: Reloading Modules
in thread Reloading Modules

This is interesting!

If you're importing subs, you must also replace them in the importing package. It's best to call import() on the reloaded package specifically. Observe:

use QStat; foo(); print "QStat foo is: ", \&QStat::foo, "\n"; print "Imported foo is: ", \&main::foo, "\n"; <STDIN>; my $loc = $INC{QStat}; delete $INC{QStat}; require $loc; # slightly more difficult # QStat->import(); print "After import, foo is: ", \&main::foo, "\n"; print "And in the package it is: ", \&QStat::foo, "\n";
Try it with and without the import(), and you'll see what's going on. *foo in the main package and *foo in QStat will point to different CVs, and that's the problem. (The STDIN part is in there so I could change what foo() does while the program is running.)

I wonder if it would be worth writing a 'reimport' module...