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

Need help creating a module

Status
Not open for further replies.

greedyzebra

Technical User
Sep 5, 2001
140
0
0
US
Hi,

I'm wanting to do something that seems as though it should be very simple, but a couple of hours on google and reading through several Perl books has not yielded an answer.

I've created a module. The functions (subs) in it are readily accessible, but variables I intend to be global (accessable by the calling script) are apparently not initialized.

For example, in my .pm file I wish to have the variable $TRUE with the value equal to 1. Whenever I say "use myModule" in a script, I want the be able to type "print $TRUE" in that script (with no other declarations) and have the output be "1".

I've used h2xs to create the shell file for the module. Everything in the module works fine. There are no complaints from the compiler about unknown variables or functions (I've exported everything I wish to be seen). Only complaints, when I try the print statements above, that the value $TRUE is uninitialized.

Please help before I have a stroke :)

Thanks.
 
Nevermind. Finally found the answer. For others who might ever have this problem, my error was declaring the variables in the .pm file with "my $varName" instead of "our $varName" (for those variables I wanted to be able to view in other files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top