Adam Kensai has asked for the wisdom of the Perl Monks concerning the following question:

I've a survey form that I'm putting together, with multiple pages and some optional pages that the user would encounter depending on their responces to the prior pages. I know the how of how I'll be doing this, i.e. setting hidden value fields to track what page somebody is on and so on. My problem is that I, in my newbieness, have not the foggiest idea as to how to structure my solution. Does the bunch of code that generates each page sit in its own subroutine? Or should each page link to a new script, one that just generates the html for that page? Or am I way out of the park, and should there not even be subroutines?

My question to my fellow monks is this, "Given the things that need to be done (taking in form input, seeing which page the user is on, outputting pages) how would you folks put this/these script(s) together?" Please forgive the newbieness of the question, but it hit me that I had no idea how real programmers (i.e. those who are not me ^_^) go about putting their solutions into a bundle, and really wish I did. I can't wait to hear your thoughts on the issue, thank you in advance for your time ~Adam

Replies are listed 'Best First'.
Re: How to organize one's code
by thraxil (Prior) on Aug 06, 2002 at 15:25 UTC
      Wow, this seems like it takes the problem of organizing things out of my hands. Thank you very much, I hadn't thought such a seemingly tailor made solution existed or I'd have looked ^_^. I'd still like to hear thoughts from people on how they structure thier programs, or where they learned how to do so. I've found many places to teach me Perl, but not too many places to teach me the zen of Perl if you catch my drift. Thanks again!
Re: How to organize one's code
by neilwatson (Priest) on Aug 06, 2002 at 15:27 UTC
      Bingo! Exactly the kind of thing I was looking for! Perhaps after absorbing this I will not write code that I am embarressed to post here. Thank you very much! ~Adam

        I'm finding that I agree with a lot of tilly had to say about style, in particular commenting. Check out this node and his subsequent reply in the same thread for his ideas about how to comment. (he apparently was trying to outline the philosophy stated here)

        there are also some people who would find any discussion of style that didn't mention pod remiss, so, pod pod pod!

        good luck on your quest for style,
        --au

Re: How to organize one's code (TEMPLATES!)
by DamnDirtyApe (Curate) on Aug 06, 2002 at 17:58 UTC

    You'll quickly realize the benefits of using a templating system for your HTML code, rather than trying to generate it from within your application. CGI::Application has built-in support for HTML::Template, but works equally easily with Template Toolkit, my system of choice. Start writing your pages with templates, and before long you'll wonder how you ever got along without them. :-)


    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche