All,
My current favorite for creating sites that share central components is
CGI::Application, which integrates very tightly with HTML::Template. Both are
wonderful modules that don't reinvent the wheel, but do what they do elegantly.
Using CGI::Application as a framework, you can create a central .pm file that handles
session information, DBI connections, setting parameters and other central functions,
which then get passed down to each of the "plugins" (or .pm modules) you create for
your website.
Assuming you create your central class correctly, you can just plug new features into
the API you've created seamlessly.
Plus, because of CGI::Applications' integration with HTML::Template, it gives you an
extremely easy way to cleanly separate HTML from code, a key to good CGI development.
Because of the way it handles namespaces, it works wonderfully with mod_perl and other
persistent environments.
You'll be required to learn OO programming. If you're a relatively competent
programmer, you'll pick it up quickly enough to do some neat things in a short amount
of time.
So here's a quick rundown on how I'm using CGI::Application-
I've created a "SuperClass.pm" that sets the HTML template to use, the DBI connection,
checks for user authorization/authentication, and sets other parameters. This is the
basic API for creating other modules.
When I create a new module (like a survey module, or a user management module), I just
use "SuperClass.pm" as my base class. All the stuff created in SuperClass is
"inherited" to the new module. I then build my new module around the API created with
SuperClass. The new module plugs into the HTML::Template, the user authenication, DBI
connection and other modules in SuperClass. I can't imagine a way this could be easier
with these two modules!
You may want to learn HTML::Template first, I think it's a little simpler to use.
They're both on CPAN, of course.
Good luck! Drop me a line if you have any more questions, if I can figure these out,
any perl hacker can.
-DJCP
"Lazarev, Roman" <[EMAIL PROTECTED]> wrote:
> Dear, All
I'm in the process of writing a code for a web-site. The idea is that it has
to be modular in its features.
By saying that I mean, that there is a storage of data and I wish to run a
report against this data, all I have to
do is copy a script and hook it up to the main code like a plug-in (think of
it like adding a plug-in in a Photoshop).
The question that I'm trying to answer is - how to implement this "plug-in
mechanism" in perl?
What about performance (when some snippet of code has to be ran via "shell"
of "exec" every time a variable is passed)?
Thank you in advance!
Roman