>>>>> "Rafiq" == Rafiq Ismail (ADMIN) <[EMAIL PROTECTED]> writes:

Rafiq> Is there a neat way of dynamically loading in the appropriate control
Rafiq> subclass?  Something proven and widely used.

Load the file with a require, and then just call the appropriate
constructor using an indirect call:

        require "My/Prefix/$type"; # presuming $type has no colons
        $myClass = "My::Prefix::$type";
        my $handler = $myClass->new(@parms);

This works even in "use strict".

Also, "eval use" is pointless.  Just use "require", after first
changing the colons to slashes, as shown above.  If tainting is on,
$type will have to be taint-clean.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


Reply via email to