simeon2000 has asked for the wisdom of the Perl Monks concerning the following question:
So that now in my other programs I can simply:package ISLog::Config; use warnings; use strict; BEGIN { use Exporter(); use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); @ISA = qw( Exporter ); @EXPORT = qw(); @EXPORT_OK = qw( $dbh $cgi $tt $cgv ); %EXPORT_TAGS = ( objects => [ qw( $dbh $cgi $tt ) ], ); } use Apache::Reload; use CGI(); use DBI; use Template; use vars qw( $dbh $cgi $tt $cgv ); $tt = new Template( INCLUDE_PATH => '/var/www/template/islog' ); $dbh = DBI->connect( 'dbi:mysql:host=xxx;database=xxx', 'xxx', 'xxx' ) or die DBI->errstr(); $cgi = new CGI(); $cgv = $cgi->Vars(); 1;
And Ta-daaaaa! I've got shared variables. Right? However, I've hit a snag. The database handler and CGI objects copy over fine 98% of the time, but the $cgv (which holds the $cgi->Vars() hashref) copies over empty on form submission scripts over 80% of the time. Every now and then it works, but mostly it doesn't. I've tried httpd -X and quite a few other things, but it just doesn't seem to work.use ISLog::Config qw/ :objects $cgv /;
I recently tried adding the following two lines to the Config module:
at the bottom of the Config module to debug, and then almost magically, the $cgv hash was then populated in the calling script @_@. I'm going nuts here. Is there a bug in CGI under mod_perl? Am I just doing it stupid? Should I just give up this crazy import stuff? Any documentation, ideas, or LARTs would be appreciated. BTW this is latest && greatest mod_perl/apache.print $cgi->header(); print "$_" for keys %$cgv;
--
perl -e "print qq/just another perl hacker who doesn't grok japh\n/"
simeon2000|http://holdren.net/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mod_perl & Exporter
by Zaxo (Archbishop) on Aug 30, 2002 at 15:01 UTC | |
|
Re: mod_perl & Exporter
by perrin (Chancellor) on Aug 30, 2002 at 15:38 UTC | |
|
Re: mod_perl & Exporter
by simeon2000 (Monk) on Aug 30, 2002 at 14:46 UTC |