Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Generic front end with back-end drivers?

by samtregar (Abbot)
on Feb 12, 2008 at 18:13 UTC ( [id://667639] : note . print w/replies, xml ) Need Help??


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