Hi Wise monks !!


I hav a problem in using Modules dynamically.. I have written a script which will fetch all the module names (*.pm) from a particular directory and its sub-dirs .
Now I hav all these names in an array and i need to call a method table_name defined in those modules.

Heres the pseudo-code form of my script .. step 1 : Getting all .pm filenames from a directory that satisfies a p +articular condition. ( in an array ) step 2 : Traverse through the array of filenames and use the module dy +namically

Something lik this ;

This is jus a snippet of my script; my @tables; foreach my $modulenames ( @avail ) { my $object = "Project::$modulenames"; use $object; my $objvalue = $object->table_name(); push (@tables, $objvalue); } print "@tables";

The Problem i hav now is I can't use my modules dynamically something like use $object ;

Thanks in advance !!!


Vishi83

A perl Script without 'strict' is like a House without Roof; Both are not Safe;

In reply to Getting Module Names Dynamically and using it by vishi83

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.