Are file scoped variables in a module duplicated with each class instantiation?

S

sln

I have a large hash that is file scoped, a lexical in the module.
Have to make quite a few instantiations of the class.
Is the file scoped lexical hash duplicated each time?
I wouldn't think so but does anybody know the quick answer?

Thanks!

sln
 
X

xhoster

I have a large hash that is file scoped, a lexical in the module.
Have to make quite a few instantiations of the class.
Is the file scoped lexical hash duplicated each time?
I wouldn't think so but does anybody know the quick answer?

Not unless you specifically do something which causes it be
duplicated.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
J

Jim Gibson

I have a large hash that is file scoped, a lexical in the module.
Have to make quite a few instantiations of the class.
Is the file scoped lexical hash duplicated each time?
I wouldn't think so but does anybody know the quick answer?

No. There is only one hash. Your file gets read and compiled only once.
There is only one lexical variable with the name of your hash. Any
instance of your class calls the methods that are defined in your class
file. Each of those methods will access the same lexical variable for
your hash. There is only one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top