Sherlock...

I personally use formats to output HTML. That with a good use of stylesheets can be very powerful. Plus, you can design the HTML in an editor and then make way for vars. A good editor like Homesite can then also make your HTML editable in the same Perl script. Just switch your language preferences.

Here is an example: (I alrady had it up...)

############################################################ # Call the format from sub "write_file" # Most HTML attributes defined via Style Sheet. ############################################################ format F = <html> <head> <title>Harris Status</title> <meta http-equiv="REFRESH" content="60; url=harstat.asp"> <link rel="STYLESHEET" type="text/css" href="ichk2.css"> <style> td.fn { color: @<<<<< ; $otxt letter-spacing : @<px; $osp } td.repct { color: @<<<<< ; $repcol } </style> </head> <body background="sandston.gif"> <p align=center>Harris Status as of <%= Now() %> <table width="300" height="100"> <tr> <td bgcolor=@<<<<> $stat{images1} <div align="center" class="sname"> Images 1 <img src=@<<<<<<<<<<<> $light{images1} </div> </td> <td bgcolor=@<<<<> $stat{images3} <div align="center" class="sname"> Images 3 <img src=@<<<<<<<<<<<> $light{images3} </div> </td> </tr> <tr> <td colspan="2"> <div class="rep"> <U>Current Replication Status</U> <table width=290><tr> <td class=server>@<<<<<<<< </td><td class=date>@<<<<<<<< </td><td clas +s=time>@<<<<<<<< </td><td class=repct> @<<<< </td> $images1[0], $images1[1], $images1[2], $images1[3] </tr><tr> <td class=server>@<<<<<<<< </td><td class=date>@<<<<<<<< </td><td clas +s=time>@<<<<<<<< </td><td class=repct> @<<<< </td> $images3[0], $images3[1], $images3[2], $images3[3] </tr></table> </div> <div class=ottl> Files to be Output: <B>@>>></b></div> $fct <div class="out"> <table width=290> ~~ <tr><td class="fn">^>>>>>>>>>>>>>>>>>>>>>>></td></tr> $outpt </table></div> </td></tr> </table> </body> </html> .

By using classes and stylesheets, I can change the appearance of my output in a completely separate file. (And in the case of daemons, without stopping and starting for every "new compile".) I also use style declarations in the HTML (cascading baby) to define things that I would like the program to be able to alter.

I personally find CGI.pm to be too much of a pain. I think the $co->h1(->p('EEEK!')); #screw syntax method of writing this stuff is godawful. Plus, between this and Tk, I get tired of typing "->" and "=>" all the friggin' time.

The fact of it is, TMTOWTDI... I think the block printing code will be much easier to maintain. Plus, if you read Saint Larry's thoughts on Perl 6, the syntax for the top example looks to be changing (not soon of course) while the second example looks to have stable syntax. While this is not an immediate issue, do you want to have to learn the OO methods for CGI.pm again when you go to modify this code? (Hmmm, rewrite it in Perl 6 or dig up my old Perl 5 black book and try to figure it out.)

Ask this, will you be the only one maintaining the code?? Do you want to be?? If you would like the flexability of allowing users to change the look and feel, using my method with a stylesheet is muy convenient. (On many programs the users have their own stylesheets and can modify the program UI individually.) If not, If you think that maintenance will be done by some other Perl God, and you'd like to keep the uninitiated out of it, use the OO methods to really obfuscate your code.

Whatever works for you.


In reply to Re: Interactive Form Creation/Maintenance by HamNRye
in thread Interactive Form Creation/Maintenance by Sherlock

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.