Thread Problem beim auslesen einer *.txt Datei!: Problem beim auslesen einer *.txt Datei! (18 answers)
Opened by Gast at 2003-12-15 12:13

Strat
 2003-12-15 17:00
#521 #521
User since
2003-08-04
5246 Artikel
ModeratorIn
[Homepage] [default_avatar]
Habe dein script mal ein wenig umgeschrieben, sodass es 1. funktioniert und 2. auch mit use strict; und use warnings; laeuft

Der Fehler war: das script hiess nicht index.pl, wonach gesucht wurde, sondern indexneu.pl, und deshalb hat es den scriptnamen in choices.txt nicht finden koennen
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! C:\Perl\bin\perl.exe
use warnings;
use strict;

my @choices = ();
my $fileChoices = "../data/choices.txt";

print "Content-type: text/html\n\n";
print "<html><h1>Hello</h1></html>\n";

print "<head>\n";
print "<title>TEST1</title>\n";
print "</head>\n";

my @mychoices = &getmychoices($fileChoices);

print qq~<body link="#000000" bgcolor="#F0F2FF">\n~;

print "<table border=\"1\">\n";
print "<tr>\n";
print "<td width=\"80\" height=\"200\">Select Stadt</td>\n";
print
"<td width=\"80\" font face=\"arial\" size=\"2\"><select name=\"stadt\" size=\"1\" style=\"width: 100px\">\n";

for ( &getchoices("stadt") ) {
print qq~<option value="$_">$_</option>\n~;
}

print "</select></font></td></tr>\n";

print "<tr>\n";
print "<td width=\"80\" height=\"200\">Select Daten</td>\n";
print
"<td font face=\"arial\" size=\"2\"><select name=\"daten\" size=\"1\" style=\"width: 100px\">\n";

for ( getchoices("daten") ) {
my @typ_split = split( /\|\|/, $_ );
print "<option value=\"$_\">$typ_split[0]</option>\n";
}

print "</select></font></td></tr>\n";
print "</table>\n";

print "</body>\n";
print "</html>\n";

# ------------------------------------------------------------
sub getchoices {
my @back = ();
pop(@back);
my $on = 0;

for (@mychoices) {
if ( $_ =~ /<\#$_[0]>/ ) { $on = 0; }
if ( $on == 1 ) { push( @back, $_ ); }
if ( $_ =~ /<$_[0]>/ ) { $on = 1; }
}

print "$on\n";


return @back;
} # getchoices

# ------------------------------------------------------------
sub getmychoices {
my ($fileChoices) = @_;

unless ( open( ALT, $fileChoices ) ) {
print " Konnte datei '$fileChoices' nicht oeffnen: $!\n";
exit 0;
}

my @choices = <ALT>;
chomp(@choices);
close(ALT);

my $self_name = substr( $0, rindex( $0, "\\" ) + 1 );
my $self_path = substr( $0, 0, rindex( $0, "\\" ) + 1 );

my @mychoices = ();
my $on = 0;
for (@choices) {
if ( $_ =~ /<!!>end choices.+$self_name<!!>/ ) { $on = 0; }

if ( $on == 1 ) { push( @mychoices, $_ ); }

if ( $_ =~ /<!!>start choices for $self_name<!!>/ ) { $on = 1; }
} # for

return (@mychoices);
} # getmychoices
# ------------------------------------------------------------
perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/

View full thread Problem beim auslesen einer *.txt Datei!: Problem beim auslesen einer *.txt Datei!