[H-GEN] CGI Troubles.

Jason Henry Parker jasonp at uq.net.au
Mon May 14 23:36:06 EDT 2001


[ Humbug *General* list - semi-serious discussions about Humbug and  ]
[ Unix-related topics.  Please observe the list's charter.           ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]

On Tue, May 15, 2001 at 12:27:08PM +1000, Brent Wesley wrote:

> #!/usr/bin/perl -w
> 
> use strict;
> use CGI qw(:standard);
> 
> my $page = new CGI();
> print $page->header;
> 
> $page->start_html('Hello World');

That's a no-op.

> print "Hello World!\n";
> 
> $page->end_html;

And so is this.

The CGI object returned by new() knows nothing about the business end
of the connection; to have it send HTML back to the client you have to
do something more like this:

  #!/usr/bin/perl -w

  use strict;
  use CGI qw/:standard/;

  my $page = CGI->new; # Indirect object syntax sucks

  print $page->header,
    $page->start_html('Hello World'),
    'Hello World!',
    $page->end_html;

Your script ends up being broken because it says the content-type is
text/html but the content sent back doesn't contain a single HTML tag.

> Have Fun.

I am.  Thanks.

jason, overjoyed to have an opportunity to retaliate against late-night
       Emacs trolls
-- 
||----|---|------------|--|-------|------|-----------|-|     |--||----|-|
| Jason Henry Parker                      play:        jasonp at uq.net.au |
| Available on #soc.bi on openprojects    work:  jparker at pisoftware.com |
||--|--------|--------------|----|-------------|------|---------|-----|-|

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list