in reply to CGI.pm question

I would like to suggest the following modifications:

   #!/usr/bin/perl -wT    #set warn and taint flags
   use strict;   #strict syntax checking

   use CGI qw/:standard :html3/;
   print "Content-type: text/html\n\n";
   etc.

You don't need the ":html3" for this little snippet, but you soon will if you start using the html shortcuts (recommended) and want to do anything more than simple pages. The standard feature set for CGI.pm (loaded by ":standard") only supports HTML 2.0 tags.

With "use strict;", you will need to declare $foo as "my $foo =..."

See the perl documentation for examples of the html shortcuts, which IMO make perl CGI progs which generate HTML far more readable, and also for more info on perl warnings, taint mode, and strict.

Replies are listed 'Best First'.
Re: Re: CGI.pm question
by Fastolfe (Vicar) on Apr 14, 2001 at 04:44 UTC
    The standard feature set for CGI.pm (loaded by ":standard") only supports HTML 2.0 tags.

    I don't know what version of CGI.pm you're using, but mine (2.56) has this to say on the topic of :standard:

    :standard Import "standard" features, 'html2', 'html3', 'form' and 'cgi'.
    Excellent advice though.
      Silly me, I went back in time (& nearly 20 minor revision levels). Thanks for waking me up.
Re: Re: CGI.pm question
by Beatnik (Parson) on Apr 14, 2001 at 15:03 UTC
    ofcourse you could drop print "Content-type: text/html\n\n"; and let CGI.pm do the header handling... like gryphon did above

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      Yes, I could; and in what passes for my real life I do. I merely copied the original poster's code and (for better or worse) made the points that I wanted to make.   Others, as you note, had already given examples of the use of HTML shortcuts, so I didn't want to plow the same furrow.