On 10/07/2006 10:27 PM, Shawn Hinchy wrote:
Hello all,
I am writing many cgi scripts and need to have the same variables
included in each of them. I was going to put all these 'global'
variables in a separate file that could then be included in the top of
each cgi script. I am already doing a similar thing with functions and
requiring that .pl file. The problem is that I cannot get the variables
to show in the main cgi script.
To include the subroutines I do this:
require './utilities.pl';
In the utilities.pl file I have this:
#!/usr/bin/perl -wT
sub foo {}
1;
I tried adding the variables to the top of this file, declared as my,
local and our. None of them worked.
I tried making a separate variables.pl file such as:
my globalvariable = '';
Use package variables for this purpose:
our globalvariable = '';
which I then tried to include using:
require './variables.pl';
use './variables.pl';
do './variables.pl';
None of these worked. I read the perldoc for each of these functions
and 'do' looks like the best candidate but I cannot get it to work. I
am sure it is something small I am overlooking.
Any suggestions?
[...]
Use package variables. Variables created with "my" will be restricted to
either file scope or block scope.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>