Answer the question
In order to leave comments, you need to log in
I want global script variables to be seen in the module, is it possible?
I am writing a program with the following architecture:
/global.cgi - инициализирующий скрипт, ловящий переменную с задачей и решающей, какой модуль подгрузить (action.pm)
/lib/module.pm - модуль часто используемых функций
/lib/action1.pm - модуль конкретной задачи
/lib/action2.pm - модуль конкретной задачи
/lib/action3.pm - модуль конкретной задачи
Answer the question
In order to leave comments, you need to log in
Make a separate caching module, where you put the variable with the cache and all the standard methods for working with it (get, set, etc.), then put the settings and cached data of different sites in the cache under different keys, and with each click, simply assign the data for the desired key as the current . Those. there will be a global cache for everyone and a cache for a specific site. It is possible to make cache variables available everywhere, but it is better to make them available through the functions of the caching module.
PS The object-oriented nature of the module specifically in this task will not help you in any way.
Well, since the hash with the settings needs to be transferred, it must be transferred.
If the initializer loads modules according to the received commands, this is probably done in one place of the script and it is not clear what the problem is G)
Well, it will pass this reference to the hash as the first parameter ...
If there is OOP, then it will not be passing a function parameter, but a constructor call with initialization by these parameters, in general the form will change.
Alternatively, you can save this hash in a file / database, and load it in modules.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question