http://www.perlmonks.org?node_id=667639


in reply to Generic front end with back-end drivers?

This should be pretty easy to do. Put each parser in a separate package with a common interface. Then in your front-end class, do:

if ($type eq 'foo') { $parser = "Parser::Foo"; } elsif ($type eq 'bar') { $parser = "Parser::Bar"; } else { die "What the heck is $type?"; } eval "use $parser" or die "Can't load $parser: $@";

Then you make calls to your parser via the package name:

$parser->do_that_thing($with_this);

-sam