BerntB has asked for the wisdom of the Perl Monks concerning the following question:
This works but I wonder about efficiency. Two questions:return if $class->can('new'); eval "use $class"; croak("Err etc") if $@;
I found an alternative to can a while ago by searching the usual suspects (Google, my books, monks). To see if the package is loaded, check for a package's symbol table:
return if defined %{$class . "::"};
This symbol table test didn't work consistently for me? Should it -- did I do something wrong?
Yes, I am optimizing the wrong details. I haven't kludged around with the symbol tables much and is fishing a bit for discussion and pointers. :)
Maybe I should just get some more books, but I am looking for work right now. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Most effective way to dynamically load a module?
by tilly (Archbishop) on Aug 22, 2006 at 04:06 UTC | |
by BerntB (Deacon) on Aug 22, 2006 at 04:12 UTC | |
by tilly (Archbishop) on Aug 22, 2006 at 05:15 UTC | |
by BerntB (Deacon) on Aug 22, 2006 at 05:47 UTC | |
by friedo (Prior) on Aug 22, 2006 at 04:15 UTC | |
by tilly (Archbishop) on Aug 22, 2006 at 05:20 UTC | |
|
Re: Most effective way to dynamically load a module?
by jbrugger (Parson) on Aug 22, 2006 at 05:04 UTC |