Rob Thompson on 27 March 2002 11:33 wrote:
> OK... does anyone know of any good reason why I shouldn't do this to
> determine which packages/objects I use at runtime?

Nope, that's the beauty of perl and eval. You can do everything at run time
if you want.

In fact, there are some more clever techniques available:

1. Using the stash entry to see if you need to do the require:

if (!defined ${report::}{$objtype}) {
    eval "require report::$objtype;"; }

2. The methods don't have to be loaded until you need them (via AUTOLOAD).

3. Using storable to persist objects, you can restore an object before its
class has been required in (bless does not need anything in the package
namespace, and the ->new method is not used to construct objects in
restore).

I am doing some interesting stuff with dynamic classes and dynamic objects.
There may be a CPAN module or two coming out of it.

Ivor.


Reply via email to