I'm having some issues with dynamically requiring perl mods ( see node:650816 )
I've tried using Module::Pluggable Module::List::Pluggable and a few of my own homebrew ideas - but nothing is working as i want it to. perl either spits errors on finding the files or on addressing package vars
package main;
use warnings;
use strict;
use lib '/';
use com_2xlp::Test::SuperClass ();
package com_2xlp::Test::SuperClass;
use warnings;
use strict;
use Module::List::Pluggable();
our %_REGISTERED_NETWORKS;
Module::List::Pluggable::import_modules( "com_2xlp::Test" );
sub register_subclass {
my ($package)= @_;
print $package;
print $package::var;
}
1;
package com_2xlp::Test::SuperClass::SubClass;
use warnings;
use strict;
our $var= "var";
com_2xlp::Test::SuperClass::register_subclass(__PACKAGE__);
1;
in the code above ( i created a /com_2xlp dir to simplify namespace issues on testing ) the subclass module will correctly call register_subclass -- evidenced by the print command. however the package vars are uninitialized if i try to address $package::var . similarly, perl will toss errors if i try to require $package or anything similar, unable to find the package.
can anyone give some suggestions on what i'm doing wrong?
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.