#!/usr/local/bin/perl use CGI qw(:cgi); print "Content-type: text/plain\n\n"; $sentence = param('sentence'); $whattodo = param('whattodo'); if ($whattodo eq "addtostory") { #open file on server # >> means we are appending # die is in case our permissions are off open(OURDATA,">>corpsefile") || die ("something is wrong\n"); #print what we want to save to the end of the file print OURDATA "$sentence"; close(OURDATA); print "Ok, your sentence was added to the story."; } elsif ($whattodo eq "getstory") { open(OURDATA, "corpsefile" )|| die ("Could not open it\n"); #go into a loop opening one line at a time while ($line = ) { print "$line"; } }