in reply to mod_perl and modules (Or "how do I import subs into my PerlHandler module)

Here are some snippets: my PerlHandler module does something like that:
use QMM::photo::qmm_photo qw(get_usr_params);
and in package qmm_photo;
package QMM::photo::qmm_photo ; #use strict; use Exporter; use DBI; use lib "/home/loic/server" ; our @ISA = ('Exporter'); our @EXPORT = qw( get_usr_params );
Without the explicit use QMM::photo::qmm_photo qw(...) ; my main module wouldn't load the funcs properly.

Replies are listed 'Best First'.
Re: Re: mod_perl and modules (Or "how do I import subs into my PerlHandler module)
by UnderMine (Friar) on Nov 22, 2002 at 12:14 UTC
    Try removing the our as @ISA and @EXPORT are special variables and are not related to the package scope..
    package QMM::photo::qmm_photo ; use strict; use Exporter; use DBI; use lib "/home/loic/server" ; @ISA = ('Exporter'); @EXPORT = qw( get_usr_params );
    Hope it Helps
    UnderMine
Re: Re: mod_perl and modules (Or "how do I import subs into my PerlHandler module)
by perrin (Chancellor) on Nov 22, 2002 at 14:28 UTC
    If you want to refer to subs defined in another package you do have to use the package prefix or import them. That's the perl5 way. There are people who make perl4-style library files with no package declaration that just add their subs to the current package when you use them, but this is a bad practice and should be avoided.

    The only mod_perl-specific issue is that if you run your script under Apache::Registry and use the same perl4-style library file in two scripts, the second one to run will not find the subs (because it's in a different package).

      Hum.
      Well usually everything in @EXPORT is exported by default when under normal use, and only stuff in EXPORT_OOK has to be exported explicitely.
      Apparently (from my experience, but I might do something wrong) under mod_perl, you'd better import everything explicitely else it won't work.
        mod_perl should not affect the behavior of the exporter. I think there must be something else going on.