in reply to Re: Formatting CGI
in thread Formatting CGI

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,

Replies are listed 'Best First'.
RE: RE: Re: Formatting CGI
by btrott (Parson) on Apr 07, 2000 at 00:18 UTC
    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!