We don't bite newbies here... much | |
PerlMonks |
Re: Accessing Variables in Different Subroutinesby sauoq (Abbot) |
on Mar 19, 2015 at 18:42 UTC ( [id://1120638]=note: print w/replies, xml ) | Need Help?? |
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.
-sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom
|
|