Dieter wrote:
> Hi,
>
> here I'd like to ask for your advice how to
> generally code a certain task, not for the details.
>
> O.K.- I try to express myself clearly:
>
> * There's a HTML-form from which the user can choose
> many different options (about 15) simultanously in
> all possible combinations for a variable number of items
> (batch mode).
>
> So e.g. lets say, she can enter "apple, peach, cherry"
> and request "color, taste, shape, short description"
> out of a set of many other options.
>
> * The CGI-script constructs a statement, depending on the desired
> information and queries the MySQL database.
>
> * Depending on what kind of information was requested,
> the output from the database is formatted differentially
> (headers, linebreaks ... ) and sent to the user.
>
>
> Now, the system already runs fine just for a few options.
> But with a about 15 options in different combinations
> I don't want to end up with endless numbers of "if"-clauses.
>
> Do you know a elegant solution, how to manage all the
> different optional parameters ?
>
> The problem appears on three stages:
>
> * Parsing the POST data (request)
> * Constructing the query for the database
> * Handling the output
>
>
> Maybe there are Perl modules to faciliate this kind of task ?
I have to second Anno's suggestion that you look very hard at a
"dispatch table" setup using a hash. Very powerful stuff. You agreed
somewhat, but then I saw you spit out some more nested "if" constructs,
so I think it worthwhile to second Anno's suggestion on this method (eg.
dispatching).
Secondly, at the risk of further complicating things for you, if you are
willing to take the time to thoroughly understand it, an recent article
by Randal Schwartz may be helpful to you (from _Linux Magazine_, Feb 2004):
http://www.linux-mag.com/2004-02/perl_01.html
Also consider in your "web application mix" not only Class:

rototype
(mentioned in Randal's article), but maybe even CGI::Application, and I
can't even imagine doing a web application without HTML::Template. At
the very least, HTML::Template can help get your mind off the
presentation layer and it's "connection" to your logic and allow you to
just focus on your logic.
Aside from the hint about dispatch tables, the rest of my suggestions
require some familiarization with Perl beyond the beginning stages;
judge for yourself to what level of Perl prowess you would place
yourself. But the article above could be helpful to you. Certainly
your discussion reminded me of it.
-ceo