Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to share variables 1

Status
Not open for further replies.

stones1030

Programmer
May 30, 2006
15
US
Can someone tell me how to do this?
I have a script A which should set some variables var1,var2.
script A will call script B which should be able to access var1 and var2 values as set by script A.

var1 and var2 can be anywhere as long as they are set by script A and accessible by script B. I mean system variables/global variables.
ANy help will be appreciated

I tried using 'our' . It didn't work.
Thanks,
Stones

 
By calling script B, what is the actual code doing? A system call, module reference, require statement?

- George
 
As of now I plan on invoking it as a system call. This is what I have
script A will be a wrapper which will calll scripts B,C,D,E based on user input. I want to save these user input values somewhere before invoking either one of B,C,D,E scripts.So I thought(with my limited knowledge) of placing these input values in another common script called common.pl. I basically want to put all the common variables and subroutines in common.pl. Script A should set these common variables and run scripts B,C,D,E as system calls and should be able to retrieve the values.

Is this possible or make sense?
Is there a better way of achieving this?
 
Since you mention user input, I'm assumming this is a CGI script though, take a look at CGI::Session. It does everything you're looking for.

If I'm mistaken, I'd suggest setting environment variables with your data that you just delete upon completing the script. Alternatively, you could store this information in a text file named using an MD5 hash (or equivalent method) and upon making the system call, pass the hash as an argument.

- George
 
This might be the last question.
Can you tell me what to use to set/get env. variables? I can get more details on how to use from the perl book i have, if I know what to use.
thanks,
 
I think i found the answer to my last Q. I should be using %ENV.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top