On Mon, Mar 29, 2004 at 03:23:46PM +0200, messmate wrote:
> comme je suis pas sp�cialiste en programmation perl,

C'est vaguement HS.

> Use of uninitialized value in string eq at
> ~/Bayes/SB-score-files.pl line 97.
>  Unable to open ~/Bayes/tmp/worddb for read at /home/eric/Bayes/
> SB-score-files.pl line17.

>     open(FILE, "<$fname") || die "Unable to open $fname for read";

Il vaut mieux:

use IO::File;

open($file, "<$fname") || die "...";
while (<$file>) {}
close $file;

>  xx   open(FILE, "<$fname") || die "Unable to open $fname for read"; 

die "Unable to open $fname: $!\n"
histoire de savoir quelle est l'erreur.

> xx     if ($ARGV[0] eq "-d") {       

Ben, si tu appelles ton programme sans argument, $ARGV[0]
n'est pas d�finit...

    if ( defined $ARGV[0] and $ARGV[0] eq "-d" ) {


>     socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Unable to create
> socket";    my $sun = sockaddr_un($path);
>     my ($score);
>     if (connect(SOCK, $sun)) {
>       select SOCK; $|=1; select STDOUT;

Berk. man IO::Socket, man IO::Select, et oublie tout �a a
jamais.

> socket";      my $unbound;
>       unless (bind(SOCK, $sun)) {
>           warn "Unable to bind to $path";
>           $unbound=1;
>       }
>       listen(SOCK, 5);
>       my ($scores) = load_wordscores("~/Bayes/tmp/worddb");

Je ne crois pas que Perl interpole '~', d'o� l'erreur dans
load_wordscores ("File not found", je parie). Essaie
        my ($scores) = load_wordscores("$ENV{HOME}/Bayes/tmp/worddb");

>       printf "%.3f\n",  ($score = file_score($ARGV[0], $scores) );
>       unless ($unbound) {
>           print "I should start a daemon\n";
>           if (1) {
>               my ($childpid) = fork;
>               if ($childpid == 0) {
>                   daemon("SOCK", $scores);
>                   exit(1);
>               }
>           }

Si je comprend bien, tu d�marres un d�mon qui lit un
fichier, puis ensuite des clients se connectent au d�mon
pour lire le fichier? Question �vidente: WTF? pourquoi ne
pas lire le fichier depuis le client et laisser tomber tout
ce code inutile?!

Y.

Répondre à