in reply to Re: ?Re: Generic Composite Interface
in thread Generic Composite Interface
If you're gonna call new, you're gonna have to ensure that the package is loaded. See how the LWP moudules do it for the various protocol handlers. It's a mere matter of coding up a proper require dynamically. No big deal, but you have to do it, true.my $logger = ${loggertyp}->new();
Or, you can add something like the following subroutine (untested):
sub UNIVERSAL::AUTOLOAD { my ($pack, $meth) = $AUTOLOAD =~ /(.*)::(.*)/; die "do you really want me to pull in $pack for $meth?\n" unless $me +th eq "new"; eval "require $pack"; die $@ if $@; die "$pack didn't define $meth" unless defined &$AUTOLOAD; goto &$AUTOLOAD; }
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ?Re: Re: ?Re: Generic Composite Interface
by chhe (Sexton) on Mar 24, 2002 at 17:41 UTC | |
by merlyn (Sage) on Mar 24, 2002 at 17:45 UTC | |
by chhe (Sexton) on Mar 24, 2002 at 21:58 UTC |