Background
I'm developing a server framework (based on Net::Server). I want the framework extensible enuff
so it will load modules at runtime dynamically, ie, there are no
config files anywhere explicitly stating what modules are where.
Problem
I'm doing a search with file::find in for any file within a specified path.
I can find the modules i'm after and require them, however when i go to
access the new method I'm finding out:
Can't locate object method "new" via package
"api::bess::query::Query" (perhaps you forgot
to load "api::bess::query::Query"?)
To stave off the obvious, yes there is a new method in the Object being loaded, and I know its loaded
as I created a BEGIN block that printed to a logfile. I'm now wondering what might be causing the problem and how i can fix it.
Snippet below:
sub load_api_modules{
my $self = shift;
my @superclass = split(/\//, $File::Find::dir);
my @class = split(/./, $_);
if ($File::Find::name =~ /\.pm$/) {
require "$_";
my $name = $File::Find::name;
$name =~ s/\//\:\:/g; # Convert slashes (/) to ::
substr($name, -3,3, ''); # Remove the .pm at the end
$self->{_$superclass[1].$superclass[2]} = new $name;
print STDERR $File::Find::name."\n";
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.