sshevlin has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a CGI pgm in which I declare global variables at startup (main):
I then proceed to check/set cookies, via a subroutine that populates the $COOKIE_ID & $COOKIE_NAME variables. My problem is that once the subroutines are exited the values they set are lost. Any ideas? Would referencing the variables in the subroutines a/p the following help: $main::COOKIE_ID????use strict; use CGI; use DBI; my ($COOKIE_ID, $COOKIE_NAME, $CGI, $DBH);
Edit by tye to add <code> tags
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Setting Global Variable in Sub
by stephen (Priest) on Apr 30, 2002 at 16:17 UTC | |
Re: Setting Global Variable in Sub
by mandog (Curate) on Apr 30, 2002 at 16:50 UTC | |
Re: Setting Global Variable in Sub
by derby (Abbot) on Apr 30, 2002 at 15:27 UTC | |
Re: Setting Global Variable in Sub
by Molt (Chaplain) on Apr 30, 2002 at 15:49 UTC | |
Re: Setting Global Variable in CGI scripts
by lestrrat (Deacon) on Apr 30, 2002 at 15:19 UTC | |
Re: Setting Global Variable in Sub
by Rex(Wrecks) (Curate) on Apr 30, 2002 at 15:57 UTC |
Back to
Seekers of Perl Wisdom