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: ... |
Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.