# # The "outline" option recursively calls this function to print a chapter # and see if it has any subchapters. # sub outline_tree { if (-e "$story_dir/$_[0].txt") { $auth = ""; $title = ""; if (open(CHAPTER, "$story_dir/$_[0].txt")) { $auth = ; $junk = ; $title = ; close(CHAPTER); chomp($auth); chomp($title); if ($auth ne "") { $auth = "by $auth"; } } #print "   "; print " | " x ($_[1] - 1); print " +-"; $x = format_chapter_number($_[1] - 1); print "Chapter $_[1]: $title $auth\n"; outline_tree(2 * $_[0], $_[1] + 1); outline_tree((2 * $_[0]) + 1, $_[1] + 1); $chapter_count++ } } # # Do some fancy formatting on the chapter numbers, so that they # don't print out in scientific notation. This only becomes # necessary when users enter chapters more than 50 levels deep!!! # sub format_chapter_number { my $my_chapter_number = $_[0]; # Parameter is chapter number. return(sprintf("%.0f", $my_chapter_number)); }