in reply to Accessing Variables in Different Subroutines
1 - If I instantiate a variable outwith the subroutines and give it a value in one subroutine, I am unable to get that value in subsequent subroutines.
You are only calling one subroutine per execution. This should be obvious to you because you call it with $execute->(); and immediately thereafter, you exit;.
The mistake you are making is pretty common for people who are brand new to web development. You are thinking that multiple calls to your CGI script are handled within one execution of the script. That's not the case. The script is executing anew each time you submit your form.
There are different ways around this, but the most common one is to use a cookie to maintain state. Although you can store the state information directly in the cookie, that's not a very robust way to do it. A better way is to store the data on the server somewhere (often in a database) and then use the cookie as a key to get to that data.
|Replies are listed 'Best First'.|
Re^2: Accessing Variables in Different Subroutines
by stefl (Acolyte) on Mar 20, 2015 at 08:38 UTC