> In my limited understanding then,  in the startup.pl, one could do the
> following:
>
> use strict;
> use MyMod::Config();
>
> MyMod::Config::load();

Yes.  Then you can have a function for accessing the config variables,
or put them in globals ($MyMod::Config::database_password), or various
other things.

> What about existing components the are normally created in scripts
using
> new..
> use strict;
> use MyMod::Config();
>
> my $config = MyMod::Config->new();

What about them?  That's a lexical variable, and not a problem.

> Since the use of globals is bad,  should existing things be converted
to
> pure packages instead of oop classes.
>
> Is it prefered in the mod_perl world to create packages rather than
classes?

I think you're getting your terminology a little mixed up.  In Perl,
packages are classes.  And I'm not sure what globals you're talking
about.

> What about statefull vs. stateless objects?

Since users are not guaranteed to return to the same Apache process each
time, you can't keep read/write data in memory between requests (at
least not without some kind of expiration system).  Read-only data, like
your config info, is fine to keep in memory.  If you want to keep some
sort of global application state, use MLDBM::Sync or Cache::Cache.  For
user sessions, look at Apache::Session.

- Perrin

Reply via email to