|Do you know where your variables are?|
Perl Variables Being Retainedby oioigazza (Initiate)
|on Aug 01, 2013 at 22:08 UTC||Need Help??|
oioigazza has asked for the
wisdom of the Perl Monks concerning the following question:
I've never seen this behaviour before so am questioning my understanding of variables in a Perl CGI environment has been wrong from the start. I was always under the impression that the lifespan of a variable in a CGI script is just during the execution of that script (unless of course they are passed between pages).
I've just noticed that a variable I am using to calculate a value in a Perl CGI script is retained each time the script is called. So the net result is the variable never gets reset back to 0.
As a test, I've created a very simple CGI script to just add 1 to a variable and display it ($test++; print $test;). No other declarations. Run this as a CGI script and the numbers go 1, 2, 3, 4, 5, 6, etc. However, run this in a command shell and it always returns 1.
I'm amazed as I've never seen this behaviour before. And I'm sure I would have done with the Perl CGI I have done over the years.
Hoping someone may put me out of my misery and confirm it's a bug of some sort.
My environment is Windows 7 Ultimate 64-bit SP1, ActivePerl perl5 (revision 5 version 10 subversion 0), Windows IIS.Many thanks