I have some OO modules that I need to be declared in a particular order and must ensure that code is called in parent modules before being called in the modules that inherit from it.
First is the basic Configuration module, it establishes a DBI connection so has to come first.
use My::Config 'test'; package My::Config; sub import { my $package = shift; my $option = shift; #initialize DB connection here }
Next is my basic Object-Relational-Model code, it needs that DBI connection from the My::Config module to automatically run some code when it is initially used.
package My:ORM; use base My::Config; # Need to run My::Config::import() # Need to run My::ORM::import() or something similiar
After 'using' the two previous modules, I want to run some more code in the Model.
package My::ORM::Model; use base My::ORM;
I guess my question is, is import() being used in modules or is it like any other subroutine, I would have SUPER my way down the Config module to ensure that everything gets called in proper order?
OR? Is there another approach that I am missing that I should try? When these modules are use'd I only need the code to be run once; (for example, I don't constantly need to create a DBI connection once I have one.
In reply to OOP and import() by Herkum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |