TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to declare global variables between scripts and am having some problems.
In a script called Dispatcher.cgi.pl I declare a package called Dispatcher (see below):
Basically, I'm trying to expose $project, $release and $globalpid as global variable so other modules/script can use them.package DispatchParser; use strict; use warnings; use lib '../modules/perl'; use lib '../modules/db'; use CommonFunctions; use CGI; use DataBaseActions; use POSIX ":sys_wait_h"; use Data::Dumper; use CGI::Carp qw(fatalsToBrowser set_message); my $q = new CGI; my $username = &GetUser(); my @ValArray; our $project = $q->param('project'); our $release = $q->param('release'); our $globalpid; # defined later in script ... rest of code ...
But, in a script called TAZ.pl, I'm trying to use those variables and it's giving me a error message:
Undefined subroutine &DispatchParser::GetUser called at ../exe/TAZ.pl line 33.
Where the function GetUser is defined in the module CommonFunctions (see below).
I'm a little puzzled as to what is going on.
TAZ.pl snippet
I'm guessing it has something to do with the order I include the package ?use strict; use warnings; use lib '../modules/perl'; use lib '../modules/db'; use lib '../tsr'; use CommonFunctions; use POSIX ":sys_wait_h"; use Date::Manip; use Time_Diff; use LogIt; use DataBaseActions; use IOrate; use emailinfo; package DispatchParser; our ($project, $release, $globalpid); print "project = $project<br>\n"; my $username = &GetUser(); ### this is line 33
Any help would be greatly appreciated.
I'm calling TAZ.pl from within Dispatcher.cgi.pl.
When TAZ.pl completes it goes back to Dispatcher.cgi.pl and then that code completes.my $cmd = "/msg/spgear/tools/bin/perl ../exe/TAZ.pl \\\"$valhash{'agen +da'}\\\" now"; system("$cmd");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sharing Global variables between scripts
by tilly (Archbishop) on Apr 16, 2004 at 20:58 UTC | |
by TASdvlper (Monk) on Apr 16, 2004 at 22:28 UTC | |
by tilly (Archbishop) on Apr 16, 2004 at 23:07 UTC | |
|
Re: Sharing Global variables between scripts
by runrig (Abbot) on Apr 16, 2004 at 20:54 UTC | |
by TASdvlper (Monk) on Apr 16, 2004 at 22:25 UTC | |
|
Re: Sharing Global variables between scripts
by gjb (Vicar) on Apr 16, 2004 at 21:52 UTC | |
by TASdvlper (Monk) on Apr 16, 2004 at 22:24 UTC | |
by gjb (Vicar) on Apr 16, 2004 at 22:40 UTC | |
|
Re: Sharing Global variables between scripts
by Fletch (Bishop) on Apr 16, 2004 at 21:00 UTC | |
|
Re: Sharing Global variables between scripts
by eXile (Priest) on Apr 17, 2004 at 00:52 UTC |