|No such thing as a small change|
Changing package variable via object-instanceby BioHazard (Pilgrim)
|on Aug 25, 2003 at 17:29 UTC||Need Help??|
BioHazard has asked for the
wisdom of the Perl Monks concerning the following question:
I do have a probably simple problem but I just can not fix it. Here is my point:
I have an own module (package) which is designed to create object-instances. In this package I have a "global" variable named %config. I put the word 'global' in quotation marks, because I think that's where my problem begins. I tried my, our and double-colon namespace syntax. This hash should be equal for all created objects. So far, so good. Every object is able to access %config. The package now contains a subroutine for reloading the (changed) config-file and storing its contents into %config after parsing. At this point the hash is either empty (or not accessible anymore?) for all object instances or did not change at all. That depends on how I declared the global hash. As you can see the sub-routine is the same as the one I call at the beginning of the package (to fill %config). I even tried almost-nonsense combinations in my desperation, but I am sure it is easily possible in any other way.
My program is very complex so I chose to post a simple (pseudo) takeout - The substantial is of importance for me. The _parse_file() sub-routine is purposely missing in order to keep clarity.
Thank you very much for your suggestions, Monks.
reading between the lines is my real pleasure