I have an interesting problem. I need to be able to require a list of modules... however even though I know that the file is there, it insists it is not.
This is the sub itself:
sub loadmod(@){ shift if(ref($_[0])); $@ = 0; foreach (@_){ croak("loadmod() cannot load any packages outside of it's own pa +ckage area (RPG). Package Requested: $pack") unless($_ =~ m/^RPG::/o +); eval{ require $_ }; croak("Unable to locate $_\n\@INC includes: ".join(", ", @INC)) +if($@); } }


It is being called like this:

   loadmod qw(RPG::Item::Weapon::Spear);

Any ideas about the problem?

This is the output:
Unable to locate RPG::Item::Weapon::Spear @INC includes: E:/Perl/lib, +E:/Perl/site/lib, . at test1.pl line 5
The file requested really exists... as: RPG/Item/Weapon/Spear.pm

I'm afraid I may not be very clear, but to summerize, I want to be able to import modules using require and a sub. If I wasn't clear enough on anything, just ask.


"Wierd things happen, get used to it"

Flame ~ Lead Programmer: GMS
http://gms.uoe.org

Edit: chipmunk 2001-10-16


In reply to require $package? by Flame

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.