Hi All, My environment is Apache, mod-perl, Apache::DBI, oracle backend, everything works fine. The problem is always MY code :) I'm trying to figure out the correct/efficient way to initialize constants in a module. What I need to do is initialize various constants when Apache is started, whether hard coded, read in from a file or extracted from a database. I have managed to thoroughly confuse myself and have the following questions.
What is the difference between how a BEGIN block and an anonymous block in a module loaded into mod_perl? At different times I understand, though I probably don't understand the implications of that in a mod-perl environment. The reason I ask is: as a begin block my initializations do not take effect yet as an anonymous block they do. Or is this based in my lack of understanding of perl? Are anonymous blocks in a module only read and executed when mod-perl first loads them, ie once? Another problem is when I try to build a SELECT HTML element with a call to the CGI module. In my anonymous block all of a sudden the HTML form variables are no longer available with the CGI::param call. Yet I can build the select element later in the cgi scripts using the same variables without a problem. Huh? Did I mention I'm confused and my head hurts :} In a simpler line, should I have a use DBI() in startup.pl as well as the PerlModule Apache::DBI in httpd.conf? I will summarize and post responses. TIA Dave Code snippets #################################################### # from httpd.conf AddModule mod_perl.c PerlSetEnv ORACLE_HOME /opt/oracle PerlSetEnv DSOURCE dbi:Oracle:IMG PerlSetEnv DATACLERK public_tst PerlSetEnv PSSWD opentoall PerlModule Apache::Registry PerlModule Apache::DBI PerlWarn On PerlTaintCheck On PerlRequire /opt/apache/conf/startup.pl ################################################################# #all of startup.pl use CGI (); use COMMON (); use WSERVICES (); Apache::DBI->connect_on_init($ENV{"DSOURCE"}, $ENV{"DATACLERK"}, $ENV{"PSSWD"}, { PrintError => 1, #warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately } ); ################################################################### # WSERVICES.pm package WSERVICES; require Exporter; use strict; use COMMON; # wrapper for basic file and db manipulation use DBD::Oracle qw(:ora_types); use CGI qw/:html :cgi :form/; our(@DB_NAMES $FILE_NAME $NUMPERPAGE $GEOCODED_LIST $LOCATION); our @ISA = qw(Exporter); our @EXPORT = qw(@DB_NAMES $FILE_NAME $NUMPERPAGE, $GEOCODED_LIST $LOCATION example_sub); # As a begin block none of the following initializations occur # all subs in COMMON.pm { $NUMPERPAGE = 12; $FILE_NAME = &Readfile('file.txt'); #see COMMON.pm &Create_DB_Connection; @DB_NAMES = @{&Get_Select_List()}; &Destroy_DB_Connection; #following code destroys variables passed through CGI param sub # yet exact same call will work if called in cgi script or subroutine $GEOCODED_LIST = scrolling_list(-name=>'CITY_LOC', -default=>$LOCATION, -values=>\@DB_NAMES, -size=> 1); } sub examplesub{return 43;} 1; ###################################################### -- Dave Morgan [EMAIL PROTECTED] 403 399 2442 "perl Makefile.PL; make install;" is just way too convenient