in reply to How to create dynamic global variables
I have a array variable that have name of modules that i needed. I m geting these module names through reading array content in loop and calling the module methods.Please post the source code for what you said above, be sure to use CODE tags to wrap it.
Problem is i need to create global object variable for all the module name that are in array.It sounds like you mean that you need to access that list of modules in numerous places in your code, and so you want get at that array from many places. Well, a package variable is "global" and accessible from other modules. But the question becomes, why are you placing the modules that you need in an array variable?
array size is dynamic it could have a single module name or n number of module name. basicaly. basicaly the name of module that is in as array value is same as my moudle name. how to create dynamic global variable that can individualy hold the module object. and from this objects i can call there other methods. thanks,You are doing things in a very unorthodox way. There are plenty of CPAN modules for this type of thing, but I think you might want to read some good books on Perl programming. But anyway, here is how to do what you want:
but you really should express your overall goal and get help on working out the dynamic loading in a more "standard" way :)package X; use vars qw(@modules); @modules = qw(A B C); 1; package U; use X; warn $_ for @X::modules; 1;
-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"
|
|---|