Perhaps you're right. That was a bad example. One way CGI.pm shows its usefulness which seems to been obscured here is with deeply nested constructs (table within a table within a form, etc.).

By replacing the BEGIN/END (tag) paradigm with a nested function call paradigm, CGI all but eliminates the kind of unbalanced tag nuisances one frequently encounters when generating HTML dynamically.

IMHO, I find looking at naked HTML (in a HEREDOC or otherwise) annoying for its waste of space (I suppose XML rubs me much the same way) and its near-redundancy; I dislike typing it even more.

I suppose the advantage is better illustrated with this comparison:

<FORM METHOD='POST> <INPUT TYPE="hidden" NAME="mode" VALUE="confirm"> <TABLE BORDER=0> <TR> <TD> <TABLE WIDTH='100%'> <TR> <TH>ColA</TH> <TH>ColB</TH> <TH>ColC</TH> </TR> <TR> <TD>Value A</TD> <TD>Value B</TD> <TD>Value C</TD> </TR> <TR> <TD><INPUT TYPE="submit"></TD> <TD><INPUT TYPE="reset"</TD> <TD>&nbsp;</TD> </TR> </TABLE> </TD> </TR> </TABLE> </FORM>

Compared with:

form( { -method => 'POST' }, hidden( -name => 'mode', -value => 'confirm' ), table( { -border => 0 }, Tr( td( table( { -width => '100%' }, Tr( th( [ 'ColA','ColB','ColC' ] ), td( [ 'Value A','Value B','Value C' +] ) td( [ submit, reset, '&nbsp;' ] )) ))) ) )

Oh, you want to write all that to the browser?

print form( { -method => 'POST' }, hidden( -name => 'mode', -value => 'confirm' ), table( { -border => 0 }, Tr( td( table( { -width => '100%' }, Tr( th( [ 'ColA','ColB','ColC' ] ), td( [ 'Value A','Value B','Value C' +] ) td( [ submit, reset, '&nbsp;' ] )) ))) ) )

dmm

You can give a man a fish and feed him for a day ...
Or, you can
teach him to fish and feed him for a lifetime

In reply to Re(3): Editing Entries In A Flat Database by dmmiller2k
in thread Editing Entries In A Flat Database with cgi by koacamper

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.