Thread Problem mit einem cgi script - Interactive Story: Anfänger braucht Hilfe (7 answers)
Opened by Gast at 2006-08-31 02:16

Melanie
 2006-08-31 19:09
#8621 #8621
User since
2006-08-31
3 Artikel
BenutzerIn
[default_avatar]
OK, ich hoffe das hier ist das richtige Stück:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# 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 = <CHAPTER>;
$junk = <CHAPTER>;
$title = <CHAPTER>;
close(CHAPTER);

chomp($auth);
chomp($title);

if ($auth ne "") {
$auth = "by $auth";
}
}

#print "&nbsp;&nbsp;&nbsp;";
print "&nbsp;|&nbsp;" x ($_[1] - 1);
print "&nbsp;+-";
$x = format_chapter_number($_[1] - 1);
print "Chapter $_[1]: <a href=\"story.pl?next=$_[0]&chapter=$x\">$title</a> $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));
}


Falls nicht bitte sagen, dann poste ich das komplette script; ich wollte hier nur nicht alles zuspammen weil es doch ganz schön lang ist. :blush:

View full thread Problem mit einem cgi script - Interactive Story: Anfänger braucht Hilfe