Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > LAMP - Program Design with Perl

Reply
Thread Tools

LAMP - Program Design with Perl

 
 
ChrisO
Guest
Posts: n/a
 
      07-17-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl + LAMP / PHP JOB jon.kay@mayfieldcurzon.com Perl Misc 2 11-09-2007 11:51 PM
HP Photosmart 2610 lamp control?... s_powelson Computer Support 1 08-02-2005 04:55 PM
LAMP & J2EE as opposed to LAMP vs J2EE Ross M. Greenberg Java 6 12-24-2004 09:59 PM
Agfa Snapscan scanner lamp P and H Macguire Digital Photography 5 02-09-2004 08:57 AM
Canon S230 Focus Assist lamp Richard Digital Photography 3 01-02-2004 11:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57