in reply to Re: Reloading Modules
in thread Reloading Modules

Yes it does that for me too but when I change something in one of the modules and then make it reload the changes in whatever sub I've changed don't seem to show through.

Replies are listed 'Best First'.
Re: Re: Re: Reloading Modules
by chromatic (Archbishop) on Feb 03, 2002 at 18:23 UTC
    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...