in reply to Formatting CGI

Well... your (CGI|Perl) script will have to output HTML or something the client will understand anyway. Most simple Perl web scripts I see do something like:
print STDOUT >>EOT; <table> <tr> <td>FIRST BUTTON</td> <td>SECOND BUTTON</td> <td>THIRD BUTTON</td> </tr> <tr> <td>I AM ON THE SECOND ROW</td> <td>YOU ARE LISTENING TO ME TYPE</td> <td>MY NAME IS MORT</td> </tr> </table> EOT
So really, it's a matter of doing both. (Note that CGI.pm provides a bevy of methods for generating HTML for you. There are also nice things like Text::Template and HTML::Mason. In a simple case, there's nothing wrong with using a here doc and embedding your HTML in the script. Just don't use a page full of print statements.)

Replies are listed 'Best First'.
RE: Re: Formatting CGI
by brysonic venture (Initiate) on Apr 06, 2000 at 23:43 UTC
    I don't have any problems doing it with html, its a matter of getting the CGI to output it ie.. (This does not work)
    #!/usr/bin/perl use CGI qw/:standard :html3/; print header, start_html("Soft Bug Buddy"), $action = param('action'); print_bugform(); sub print_bugform { print start_form; print table({-border=>''}, Tr({-align=>CENTER, -valign=>TOP}, [ th([ print submit(-name=>'action',-value=>'whatever'), print submit(-name=>'action',-value=>'whomever'), print submit(-name=>'action',-value=>'wherever'), 'Some kind of text', print submit(-name=>'action',-value=>'quit') ]) ] )); }
    thx again,
      It doesn't work right because you shouldn't be print-ing the submit buttons; the submit method (as well as the other HTML methods in CGI.pm) *returns* the HTML, so you should just take the print statements out, and it should work just fine.
      th([ submit(-name=>'action', -value=>'whatever'),
      and so on.

      By the way, you don't *have* to use the CGI.pm methods if you don't want to, or if you're more comfortable just printing out HTML. Personally, I've never found much of a use for them.

      As Abigail wrote: "CGI.pm's set of methods that output html tags seems to me as useful as an English.pm module with a method for every word, and using that instead of writing plain text."

        Imagine that, after being slapped around a bit by Guy Steele, the W3C announces that, effective immediately, the official format for HTML is no longer
        -HTML- -HEAD- -TITLE-Bla-/TITLE- -/HEAD- -BODY- -IMG src="foo.bar"- -/BODY- -/HTML- -/CODE- (think &lt;&gt; instead of --), but instead <CODE> (in-html (cons (in-head (in-title "Bla")) (cons (in-body (img :source +"foo.bar")) '()))
        . Imagine also that, at the very same time, both AOL/Netscape and Microsoft have signed treaties promising that they'll follow the W3C specs by the letter. Now, if you've got a shitload of code floating around which extensively uses literal HTML (be it quoted, with here-docs, or using the __DATA__ facility), you're going to have a lot of editing to do... (and just try to cook up an HTML-to-SEXP translator script!). Whereas if you're using the CGI module's facilities, all you have to do is change a few functions here and there, and you're all set - and your CGI programs will be the only ones that work with the newest releases of Nutscrape and Exploder!