Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Variables and MOD_PERL Advice

Status
Not open for further replies.

Deleted

Technical User
Jul 17, 2003
470
US
Built several classes in OO perl that require the 'Exporter' to globalize common methods as a hashref for use within several classes.

MyStuff.pm
MyStuff/A.pm
MyStuff/B.pm

index.cgi accesses method from the A.pm and B.pm classes. MyStuff.pm is the base class accessed by the A.pm and B.pm. It contains the most common methods used by all modules. The variable $LIB is exported from the base class for use in the modules A.pm and B.pm.

$LIB contains methods of the base class

Example of method use (using $LIB) in A.pm

Code:
package A;

use vars qw($LIB);
use MyStuff qw($LIB);

sub new {
        my $class = shift;
        return bless({}, $class);
}

sub process_form {
         my $self = shift; 
         my $title = $LIB->param_int('title'); # Return CGI input

         # Do something like
         my $select = "SELECT * FROM ..............."
         my $data = $LIB->sql_hashref($select);
}

QUESTION:
Should I be worried about the use of $LIB being globalized under the MOD_PERL environment since all the modules are pre-compiled on Apache startup?

Thanks for your time..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top