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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Variables

Status
Not open for further replies.

Loon

Programmer
May 24, 2000
100
GB
Hi,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;I have several modules that need to use the same global variable in several places. This global variable is created and assigned a value in a perl script that 'uses' all the modules. <br><br>&nbsp;&nbsp;&nbsp;&nbsp;However, the variable is not keeping it's value across modules, presumably because it is not being included in the symbols table for each of the modules. Is there anyway to ensure that a variable declared in my script is readable in all modules/functions called by that script?<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Cheers!<br>Loon
 
Say that you have a module called MyVars.pm with the variable MyVariable that you wish to share across all modules/functions called by a script.<br><br>Each module/file needs the following line:<br><br>use MyVars qw('MyVariable');<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top