Hello , Hello! I have a problem and can't get it how to solve it. When I'm using 'use Module;' in if..elsif statement I've got situation when all modules is included. For example (from code snippets bellow) if I call edit_info it makes My::Info and My::Setting to be used and I can't use global variables in edit_info, only in last elsif statement (change_settings). Use of global variables is critical for this code.
I tried in this way eval ("use My::Info; &edit_info();"); It works, but in some strange manner, I need to reload page few times to make it works, before that I see module export errors in log. Can anyone suggest me someting? I'll really appreciate any help. main.cgi ======================================================= #!/usr/bin/perl -w package main; use strict; use CGI::Apache qw/:standard/; use CGI::Cookie; use Apache::DBI; use lib qw (.); use Rc::Config(); use vars qw(%cfg); *cfg = \%Rc::Config::cfg; use vars qw($dbh $q); $q = new CGI; if ($q->param('action') eq 'login') { &login(); } elsif ($q->param('action') eq 'edit_info') { use My::Info; &edit_info(); } elsif ($q->param('action') eq 'change_settings') { use My::Settings; &change_settings(); } ======================================================== My::Info.pm ======================================================== package My::Info; use strict; use lib qw(../); use Rc::Config(); use vars qw(%cfg); *cfg = \%Rc::Config::cfg; use Exporter; use vars qw(@ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter); @EXPORT = qw(edit_info $dbh $q); @EXPORT_OK = qw(); use vars qw($dbh $q); sub edit_info { .............................. } 1; ======================================================== My::Settings.pm ======================================================== package My::Settings; use strict; use lib qw(../); use Rc::Config(); use vars qw(%cfg); *cfg = \%Rc::Config::cfg; use Exporter; use vars qw(@ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter); @EXPORT = qw(change_settings $dbh $q); @EXPORT_OK = qw(); use vars qw($dbh $q); sub change_settings { .............................. } 1; ------------------------------------------- Sincerely yours, Andrey A. Kudrin, mailto:[EMAIL PROTECTED]