On Wed, 29 May 2002 09:22:00 -0400 "Aaron Ross" <[EMAIL PROTECTED]> wrote:
: > Is there a neat way of dynamically loading in the appropriate control : > subclass? Something proven and widely used. : : For what it's worth, I use the eval trick too. Although it may seem a : little clunky, I believe it is "proven and widely used". The DBI.pm : module uses code like this to load in the DBD drivers: : : my $driver_class = "DBD::$driver"; : eval "package DBI::_firesafe; require $driver_class"; I wonder, why do you program such a central module that dynamic? Why do you chose that approach instead of this one? package Dispatcher; use Controller1; # ... use ControllerN; sub handler { my $r = Apache::Request->new(shift); my $ctl = $r->param('ctl'); return Controller1::handler($r) if $ctl = 'login'; # ... return ControllerN::handler($r) if $ctl = 'show_cart'; return SERVER_ERROR; } -- fxn