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:
package X; use vars qw(@modules); @modules = qw(A B C); 1; package U; use X; warn $_ for @X::modules; 1;
but you really should express your overall goal and get help on working out the dynamic loading in a more "standard" way :)



The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"


In reply to Re: How to create dynamic global variables by metaperl
in thread How to create dynamic global variables by pankaj41483

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.