spatterson has asked for the wisdom of the Perl Monks concerning the following question:

Hi, has anyone used mod_perl with AppConfig or Exporter? I'm having some rather mad intermittent errors.

I've written a DB based photo gallery system, using mod_perl2 and Apache2.
There's a core module 'Gallery.pm', package Gallery which handles database and filesystem access, a frontend module 'Frontend.pm', no set package, which generates the display . These are in a common include directory.

Each site has its own index.pl to decide which subs from Frontend to call (i.e. whether to show an image, a set of search results etc).

I have a couple of intermittent problems

Gallery.pm exports all its subs using Exporter, they are only ever called by Frontend.pm

require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw/insert_image search exif image_tags all_tags path login_ok get_unique_filename check_md5_collision title/;

Frontend.pm exports its subs using Expoter too, they're only called by index.pl.

require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw/try_cookie frame_images entrypage tagpage imagepage rawthumb login logout/;

index.pl also uses AppConfig to load a config file containing database connection details, a few paths and page titles etc.

Hopefully this all makes sense, does anyone have any suggestions?


just another cpan module author

Replies are listed 'Best First'.
Re: Intermittent trouble with mod_perl, Apache2, AppConfig and Exporter
by perrin (Chancellor) on Jun 24, 2008 at 18:59 UTC
    The problem is that Frontend.pm is not a real module because it doesn't have a package. Once you use() it in one index.pl, it will never be loaded again in that process. If you had a package declared, it would still call the import(), which is created by Exporter, and you'd get your subs. There's more about this in the mod_perl docs.