O'Reilly logo

Sams Teach Yourself CGI in 24 Hours, Second Edition by Rafe Colburn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Posting Script

Now that you’ve seen how topics are displayed, let’s take a look at how new topics are created and how responses are added to existing topics. The post.pl script serves two purposes. First, it is used to create new topics, and second, it’s used to append responses to existing topics. The source code for the script appears in Listing 14.3.

Listing 14.3. The Source Code for post.pl
 1: #!/usr/local/bin/perl -Tw 2: 3: use CGI; 4: use strict; 5: use CGI::Carp qw(fatalsToBrowser); 6: 7: my $query = new CGI; 8: my $topic_directory = "topics"; 9: my $page_title; 10: my ($action, $author, $title, $post, $response_to) = ("","","","",""); 11: 12: print $query->header; 13: 14: if ($query->param('action')) { 15: &set_variables; 16: 17: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required