Take a step back from your application and your CGI::Application work. As you said, with CGI::Application you must return the entire content from the method call. When you generate a webpage with your existing app, your browser cannot render or display the page until it has the entire page, so it's essentially the same thing. You could just wrap your entire bit of cgi code in a sub and then return the entire page, you'd get what you want but lose any benefits.
As for how I prefer to generate content, I say follow what you call templatizing the entire page. Try to break up your different sections into their own functions, then call them to populate your template. Hmmm, looks like I answered by saying, "both."
I wasn't really exposed to this methodology until I was involved with a largish Java j2ee web project (at which point I asked, "why don't we do this in perl," after which I discovered cgi::application and another framework and realized we did) and even more so later with a portal project. Every bit of content in the portal came from it's own object/function and the portal is just there to put a nice skin on them (using a template.)
Once you start writing this way, it becomes much easier. Code reuse and all that blah blah blah. Take the chatterbox client to the right. It doesn't care about tags, it just dumps what it's got and the site takes care of it. You could wrap the chatterbox in a table cell like it is now or wrap it with html body tags and make it a page by itself.
HTH
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.