in reply to Re: Tutorials
in thread Tutorials for CGI.pm

Have you looked at the docs that come with CGI.pm? They actually have quite a few examples. If that's not enough, Lincoln also has an expanded book on that.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE:(3) Tutorials
by swiftone (Curate) on Aug 25, 2000 at 22:51 UTC
    I too started from cgi-lib, and I've always found CGI.pm's docs insufficient as a tutorial...they assume you have been using CGI.pm through it's evolution. The docs use terminology that may not be familiar to the reader. And if the original poster is like me, and doesn't wish to mix content with code, none of the HTML functions are desired.

    Original poster, my humble advice is:

    • Start by using:
      use CGI; $page = new CGI; CGI::ReadParse(); print $page->header; #Rest of stuff here
      in place of cgi-lib, &ReadParse, and &PrintHeader. The rest of the script will be the same. Immediate advantage is to be able to test your scripts off-line.
    • Next, learn the secrets of the CGI->new() syntax, and learn about how you can save state.
    • Also learn the param() and import_names() calls. Then you can get rid of ReadParse();
    • Only use the HTML functions if you want to. If you have some other methods of outputting HTML content, they can be just fine.
    • As always, use -w, use strict, and -T.
    • the header() function has many useful options, and redirect() is very nice too.