Hello everybody, I am currently struggling about how are we supposed to implement persistent variables in perl.
Let me clarify myself;
I have a Module which handle the users data, it contain a memberlist variable which is initially undefined.
My goal is to populate the list variable only once by reading a file.
The flow should theoretically be as follow :
My current tests shows that the variable either get unloaded after being populated from inside the package, or it always read the file to fetch the variables.
How am I supposed to implement this? I thought the code within package was only run at compile time unless it was within a sub.
I would still consider myself as a beginner when it come to server-side/perl programming, so don't hesitate to point out any flaws that would occur from using this kind of flow in a real-world case.
On a side note, if you have open source code that you strongly recommend studying available anywhere, please let me know. I used to read a lots about YABB Forum code but the more I read about it, the more I realize that the code is not strong / very efficient.
Thanks
###################################
Update
After further testing with the singleton patterns (Thanks McA) and my previous implementation, I have realized that the problem does not really reside in the semantics but in the way the perl software works
After a script has been executed, all the packages are unloaded from memory. Is there any way of making sure a package remain alive?
In reply to Data Persistence by ShaZe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |