I guess my first question: Are these required files just collections of subroutines with a .pm extention, or are they actual packages? Against my gut, I'll assume that they're packages, based on the .pm extension in the filename.

Based on that assumption:

#!/perl use strict; use lib qw(/path/to /another/pathto); use diffrent; use something; something::todo(arg1,arg2); diffrent::todo(arg3,arg4);
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:
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


In reply to Re: Reloading modules more than once by abaxaba
in thread Reloading modules more than once by Ashcrow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.