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

Using external global variable

Status
Not open for further replies.

Capellone

Programmer
Dec 6, 2005
4
RO
Hello,

In "script1.pl" I have a global object variable:
my $startup = new Startup($dir);
In "module.pm" I want to use variable $startup. I have strict declaration enabled. How to do this?
 
It's considered bad form for a module to poke about in it's calling script's namespace. You would be better having a function exported from module.pm which sets it's own copy of $startup or pass it as an argument on the [tt]use[/tt] line.

Yours,

fish

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top