# Read in all the variables set by the form CGI::ReadParse(*input); $month = $input{'month'}; $date = $input{'date'}; $year = $input{'year'}; #### my $month = $q->param('month'); my $date = $q->param('date'); my $year = $q->param('year'); my $title = $q->param('title'); my $message = $q->param('message'); #### #!/usr/local/bin/perl use CGI qw/:all/; my $q = new CGI; #### #!/usr/local/bin/perl -w use strict; use CGI; my $q = new CGI; #### CGI::ReadParse(*input); #### print "Content-type: text/html\n\n"; #### print $q->header(); #### if($action eq "add_data"){ print "Your post was sucessful
"; add_data(); } else{ } if($action eq "preview"){ preview(); } else{ } ##
## if($action eq "add_data") { print "Your post was sucessful
"; add_data($q, $numberoflines,$database); } elsif ($action eq "preview") { preview($q, $numberoflines); } else { print STDERR "Unrecognised action: [$action]\n"; } ##
## # in CountCurrentRecords open(DATABASE, "$database"); #### # in CountCurrentRecords $number = 1; # ... $number = 0 if $number < 0; #### # in preview print "
... #### # in add_data $addfile = "events.txt"; #### sub add_data { my ($q, $numberoflines, $addfile) = @_; # Assign intelligent defaults. my $month = $q->param('month') || 0; my $date = $q->param('date') || 0; my $year = $q->param('year') || 0; my $title = $q->param('title') || ""; my $message = $q->param('message') || ""; open(OUT, ">>$addfile") or die "Can't open $addfile\n"; my $number = $numberoflines; my $line = join '::', $number, $month, $date, $year, $title, $message; print OUT "$line\n"; close OUT; } #### if ($action eq "add_data") { print "Your post was sucessful
"; add_data($q, $numberoflines, $database); }