I agree that the mixing of code can get ugly, and this is an hour's hack and not the way I'd generally do it, but I prefer to avoid the templating way of doing it. Calling templates and passing them values can be just as ugly as bare HTML and it removes you one step from what you're actually trying to do (which is communicate through web pages).
My preferred approach is object oriented. I create a "Display" object with subs for form generation, etc. that are specific to my current problem. If I can design the interfaces to these objects well enough, I can rewrite them later for Tk or whatever other kind of user display I'm using and not have to re-write the rest of the app. This provides cleanliness in the functional code and separation from the display code but still allows you to see the HTML directly when you want to.
So far I don't know anyone else who does it this way, but I prefer it.
-the Pedro Picasso
(sourceCode == freeSpeech)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||