Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-24 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found