in reply to Reloading modules more than once
Based on that assumption:
Another option is to take advantage of polymorphism, and some OOP. This can especially be an attractive choice if you find yourself with a lot of similar code between the two files:#!/perl use strict; use lib qw(/path/to /another/pathto); use diffrent; use something; something::todo(arg1,arg2); diffrent::todo(arg3,arg4);
package something; @something::ISA=qw(basePack); sub todo { #something::todo code in here } package diffrent; @diffrent::ISA=qw(basePack); sub todo { #diffrent::todo code in here } package basePack sub new { return bless({},shift); } sub act { my $self=shift; $self->todo(@_); } #package main. #!/perl use strict; use lib qw(/path/to /another/pathto); use diffrent; use something; my $something=new something; my $diffrent = new diffrent; $something->act($arg1, $arg2); #something::todo; $diffrent->act($arg3,$arg4); #diffrent::todo;
Of course, all of this can be averted. If you know when to "reload" sub todo, then you ought to know when it should be called. Just rename one of the todo subs to something else.
| ÅßÅ×ÅßÅ
"It is a very mixed blessing to be brought back from the dead." -- Kurt Vonnegut |
|
|---|