Schrift
[thread]727[/thread]

Problem mit dem Einlesen (Seite 6)

Leser: 2


<< |< 1 ... 3 4 5 6 >| >> 56 Einträge, 6 Seiten
XeroX
 2006-06-14 10:40
#7649 #7649
User since
2006-05-17
27 Artikel
BenutzerIn
[default_avatar]
Es lag scheinbar am Readonly, Ich hab die drow_pxl.pl Daten einfach mit ins script geschrieben. Nun findet er die words.txt aber wieder nicht.

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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use strict;
use warnings;
use DBI;
use FindBin ();
use lib ('C:\Programme\xampp\htdocs\drow');

my $DB_TABLE = "drow_dictionary";
my $LANG0 = "Drow";
my $LANG1 = "Common";
my $NOTES = "Notes";

package My::Config;
use strict;

use lib ('C:/Programme/xampp/apache/bin/');
my $DATABASE = "drow";
my $DB_TABLE = "drow_dictionary";
my $DB_USERNAME = "root";
my $DB_PASSWORD = "";

loadDictionary( "words.txt" );


sub loadDictionary {
my( $DICTFILE ) = $FindBin::RealBin . $_[0];
my @lines;

# Read in the dictionary into memory
print "Reading file '$DICTFILE'...";
open( DICTFILE,'<', $DICTFILE ) || die( "Couldn't open file: $!" );;
my( @filelines ) = <DICTFILE>;
close( DICTFILE );
foreach my $line (@filelines) {
push( @lines, my $line ) if( my $line =~ m/\w/ );
}
@filelines = ();

print (0+@lines)." lines read.\n";
print "Sorting...";
@lines = sort( @lines );
print "Done.\n";

# Setup Database Connection
my $dbh = DBI->connect("DBI:mysql:$My::Config::DATABASE:localhost", $My::Config::DB_USERNAME, $My::Config::DB_PASSWORD ) ||
die( "Could not establish database connection: ".$DBI::errstr );
$dbh->do( "delete from $My::Config::DB_TABLE" );;

# Cycle through lines, adding them into database
my( $query ) ="insert into $DB_TABLE ($LANG0, $LANG1, $NOTES) values (?,?,?) ";
my $sth = $dbh->prepare($query);

foreach my $line (@lines ) {
my( $notes ) = "";
# Simple word0=word1 line
my $line =~ s/\`/\'/g; # Change back-quotes to normal quotes
my $line =~ s/\_/\ /g; # Change underscores to spaces
my $line =~ s/\+/\ /g; # Change plusses to spaces
if( my $line =~ m/^([\w\-\'\s\,\+]*)\=(.*)/ ) {
my $word1 = $1;
my $word2 = $2;

# Get rid of email address of contributed words
if( my $word2 =~ m/\=/ ) {
my $word2 = $`;
}

# Extract notes if any
if( my $word2 =~ m/\((.*)\)/) {
$notes = $1;
$notes =~ s/\'/\\\'/g;
my $word2 = $`;
}

# Split if it has commas
my( @words1, @words2 );
if( my $word1 =~ m/\,/ ) {
@words1 = split( ',', my $word1 );
} else {
@words1 = (my $word1);
}
if( my $word2 =~ m/\,/ ) {
@words2 = split( ',', my $word2 );
} else {
@words2 = (my $word2);
}

# Do all combinations if has commas
foreach my $word1 (@words1) {
foreach my $word2 (@words2) {
my $word1 = &trim( my $word1 );
my $word2 = &trim( my $word2 );
if( $notes eq "" ) {
$sth->execute(my $word1,my $word2,undef);
}
else {
$sth->execute(my $word1,my $word2,$notes);
}

}
}
} else {
warn( "Can't parse line ==my $line==\n" );
}
}

}


# Trims whitespace off start and end of string
sub trim{
my( @asz, $sz ) = @_;

foreach $sz (@asz){
$sz =~ s/^\s*(.*)$/$1/;
($sz = $`) if ($sz =~ m/\s*$/);
}
return wantarray() ? @asz : $asz[0];
}



Software error:
Couldn't open file: No such file or directory at C:/Programme/xampp/htdocs/drow/convertDictionary.pl line 30.
For help, please send mail to the webmaster (admin@localhost), giving this error message and the time and date of the error.
GwenDragon
 2006-06-14 12:24
#7650 #7650
User since
2005-01-17
14555 Artikel
Admin1
[Homepage]
user image
Wie wäre es anstatt
Code: (dl )
 my( $DICTFILE ) = $FindBin::RealBin . $_[0];

mit
Code: (dl )
 my( $DICTFILE ) = "$FindBin::RealBin/" . $_[0];

Du hast nach dem Pfad das abschließende / vergessen!
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

XeroX
 2006-06-14 18:03
#7651 #7651
User since
2006-05-17
27 Artikel
BenutzerIn
[default_avatar]
Waoh Geil es funktioniert soweit...Er verlangt von mir die SQL DAten die hab ich nun angegeben. und jetzt bekomm ich...

Quote
Die Seite kann nicht angezeigt werden.
Die gewünschte Seite kann nicht angezeigt werden.

--------------------------------------------------------------------------------

Versuchen Sie Folgendes:

Öffnen Sie die localhost -Homepage, und suchen Sie dann nach Links zu den gewünschten Informationen.
Klicken Sie auf Aktualisieren oder wiederholen Sie den Vorgang später.

Klicken Sie auf Suchen, um nach Informationen im Internet zu suchen.
Sie können auch eine Liste verwandter Sites anzeigen.




HTTP 500 - Interner Serverfehler
Internet Explorer
GwenDragon
 2006-06-14 18:24
#7652 #7652
User since
2005-01-17
14555 Artikel
Admin1
[Homepage]
user image
Füge mal in Skript am Anfang folgendes hinzu:
Code: (dl )
use CGI::Carp qw( fatalsToBrowser );


Dann wird dir angezeigt, wo der Fehler ist.

Das Skript gibt wohl keinen HTTP-Header aus.
Das geht mit
Code: (dl )
1
2
use CGI ();
print CGI::header();
\n\n

<!--EDIT|GwenDragon|1150295222-->
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

Strat
 2006-06-18 16:41
#7653 #7653
User since
2003-08-04
5246 Artikel
ModeratorIn
[Homepage] [default_avatar]
ob das script syntaktisch korrekt ist, findest du auch heraus, wenn du es in der kommandozeile folgendermaszen testest:

perl -c scriptname.pl
perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/
pq
 2006-06-18 19:42
#7654 #7654
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
[quote=XeroX,14.06.2006, 16:03]
Quote
HTTP 500 - Interner Serverfehler
Internet Explorer  
[/quote]
Wiki:Server Error 500\n\n

<!--EDIT|pq|1150645353-->
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
<< |< 1 ... 3 4 5 6 >| >> 56 Einträge, 6 Seiten



View all threads created 2006-05-17 13:33.