I asked
a very similar question a long time ago. Following the advice of the respondents, I quickly learned
HTML::Template and have never looked back. Basically, the most important advice is learn a templating system. You
will need it sooner or later.
Putting the HTML outputting code in a subroutine is the first step. If you've gotten this far, you probably realize that HTML interspersed with code can get pretty nasty. But eventually, you will need functionality more complex than just variable substitution into your HTML skeleton. At this point, instead of reinventing this very common wheel, learning a templating system will save you a lot of grief. There are several good ones out there.
And if you ever get serious about CGI scripts (as in, coding for money), you will eventually be working with designers. Take it from me, you do NOT want them opening your Perl code to tweak some HTML!
blokhead
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.