#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use CGI qw(:standard);
my $cgi = new CGI;
my $old_writer;
my $old_title;
my $old_text;
my $writer = param{'writer'};
my $title = param{'title'};
my $text = param{'text'};
my $current = param{'current'};
my $html_file ="reflections.txt";
#this filename holds the $reflection_holder variable for finsh_events.cgi
my $data_file ="reflections.dat";
#this filename holds the $data_holder variable for manipulation
my $data_holder = "$writer :: $title :: $text";
#this hold the reflection in a data form with "::" delimiters
my $reflection_holder ="$writer
$title
$text";
#this holds the reflection in an html format
#archive_holder holds the archive reflection html format
my $archive_holder = "
Reflections
Reflections
by $writer
$title
$text
";
print "Content-type: text/html\n\n";
if ($current eq "ON") {
print "
This is what will be posted on the Reflections section of the homepage.
\n";
print "by $writer
\n";
print "$title
\n";
print "$text
\n"; #$text is actually the variable that contains the reflection
#READ IN the old reflection data file before overwriting so it can be archived
open(FILE,"$data_file");
my @old_reflection=;
close FILE;
foreach my $i (@old_reflection) {
chomp($i);
($old_writer,$old_title,$old_text) = split(/\ :: /,$i);
# this is the same as $count = $count + 1;
my $count++;
}
my $the_title = "$old_title.shtml";
#current_holder holds the current reflection in html format for archiving
my $current_holder = "
Reflections
Reflections
by $old_writer
$old_title
$old_text
"; #print "
$current_holder
\n";
#store current reflections in archive
open (FILE, "+> ../../../reflections/archive/$the_title");
print FILE "$current_holder\n";
close FILE;
#create new reflection text file
open (FILE, "+> $html_file ");
print FILE " $reflection_holder\n";
close FILE;
#create new reflection data file
open (FILE, "+> $data_file ");
print FILE "$data_holder\n";
close FILE;
print "\n";
} else {
#store just entered reflection in Archive for later use
print "This will be stored in the Archive until it is used\n";
open (FILE, "+> ../../../reflections/archive/$title.shtml ");
print FILE "$archive_holder\n";
close FILE;
}