\n"; if (($author_name ne "") || ($author_email ne "")) { $author = "$author_name $author_email"; } else { $author= "an anonymous author"; } print "
\n";
while (
What do you do now?
EOF
}
} elsif ($in{'submit'} eq "") {
# The next page of the story doesn't exist.
# Ask the user to enter it.
print < Now it's your turn to enter what happens next in the story.
$next_text_1
$next_text_2
EOF
} else {
# The user has entered a next page.
# See if it's okay. If it is, save it.
# Convert newlines to
html in the story:
$in{story_text} =~ s/\n/
\n/gio;
# Don't let people create any old file:
$prev_page_num = format_chapter_number(int($in{'next'} / 2));
if (($in{'next'} ne "1") && (! -e "$story_dir/$prev_page_num.txt")) {
print "Invalid chapter name!
";
# Check for any missing text:
} elsif ($in{story_text} eq "") {
print "Please write the description of what happens now.
";
print "Press your browser's 'Back' button to add it.";
} elsif (($in{next_text_1} eq "") || ($in{next_text_2} eq "")) {
print "Please enter two options for what the user can do next.
";
print "Press your browser's 'Back' button to add this.";
} elsif ($in{chapter_title} eq "") {
print "Please enter a title for your chapter.
";
print "Press your browser's 'Back' button to add it.";
} else {
# Make sure file is still available.
if (-e $nextfile) {
print <After you select the
"See it" link, you may need to press the 'Reload' button on your browser
to see what the other person
entered.
EOF
} else {
# Save it!
if (!open(STORY, ">$nextfile")) {
print "Oh oh. I couldn't open the file '$nextfile' to save your
section. (Error: $!) So I didn't save it.\n";
} else {
print STORY "$in{author_name}\n";
print STORY "$in{author_email}\n";
print STORY "$in{chapter_title}\n";
print STORY "$in{next_text_1}\n";
print STORY "$in{next_text_2}\n";
print STORY "$in{story_text}\n";
close(STORY);
print <