FamousLongAgo has asked for the wisdom of the Perl Monks concerning the following question:
Is there a better way to do this? What is a virtuous way to add error handling here? Humble thanks in advance.my $parser; my $m = $params{'parse_method'}; # from the config file # this is a hash of parser names to modules my %flavors = ( 'POS' => 'LSI::Parser::POS', 'Regexp' => 'LSI::Parser::POS::Regexp', 'JSTOR' => 'LSI::Parser::POS::JSTOR' ); my $flavor = $flavors{ $m } || 'LSI::Parser'; # default # This is what makes me uneasy... eval "require $m" ; $self->{'parser '} = ($m)->new();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How best to require subclasses at runtime
by fglock (Vicar) on Nov 07, 2002 at 17:30 UTC | |
by Revelation (Deacon) on Nov 07, 2002 at 21:59 UTC | |
|
Re: How best to require subclasses at runtime
by webengr (Pilgrim) on Nov 07, 2002 at 18:49 UTC | |
|
Re: How best to require subclasses at runtime
by impossiblerobot (Deacon) on Nov 08, 2002 at 03:06 UTC | |
|
Re: How best to require subclasses at runtime
by Ryszard (Priest) on Nov 08, 2002 at 08:28 UTC |