This was a problem that I had when I was first starting out with mod_perl;
i.e., it wouldn't work the first or second times through, and then it would
magically start working.

This was always caused for me by a syntax error in a library file. In your
case, it could be caused by a syntax error in a library file used somewhere
in your eval'd code. I highly suggest running
> perl -c <library file>
on all of your library files to check them for valid syntax. If all of your
library files are in the same directory,
> perl -c *
will work as well.

I'm not certain for the technical reason for this, but I believe it has
something to do with the fact that syntax errors in the libraries are not in
and of themselves considered a fatal condition for loading libraries in
mod_perl, so the second or third time around the persistent mod_perl process
thinks that it has successfully loaded the library. Obviously, some
functions in that library won't work, but you won't know that unless you
actually use them. Someone else might be able to shed more light on this.

good luck,
Ed


-----Original Message-----
From: Gunther Birznieks [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 07, 2000 3:38 AM
To: Hill, David T - Belo Corporate; '[EMAIL PROTECTED]'
Subject: Re: eval statements in mod_perl


Without knowing your whole program, this could be a variety of logic
problems leading to this code. For example, perhaps $build{$nkey} is a
totally bogus value the first 2 times and hence your $evalcode is also
bogus the first two times -- and it's not a problem of eval at all!

This is unclear for the snippet.

At 10:52 AM 12/6/2000 -0600, Hill, David T - Belo Corporate wrote:
>Howdy,
>         I am running mod_perl and have created a handler that serves all
the
>pages for our intranet.  In this handler I load perl programs from file
into
>a string and run eval on the string (not in a block).  The problem is that
>for any session the code doesn't work the first or second time, then it
>works fine.  Is this a caching issue or compile-time vs. run-time issues?
I
>am sure this is a simple fix.  What am I missing?
>
>         Here is the nasty part (don't throw stones :)  So that we can
>develop, I put the eval in a loop that tries it until it returns true or
>runs 3 times.  I can't obviously leave it this way.  Any suggestions?  Here
>is the relevant chunk of code:
>
>         #  Expect perl code.  Run an eval on the code and execute it.
>                         my $evalcode = "";
>                         my $line = "";
>                         open (EVALFILE, $build{"$nkey"});
>                         while ($line = <EVALFILE>) {
>                                 $evalcode .= $line;
>                         }
>                         my $evalresult = 0;
>                         my $counter=0;
>
>#################################################################
>                 #       Temporary measure to overcome caching issue, try
to
>#
>                 #       run the eval code 3 times to get a true return.
>#
>
>#################################################################
>                         until (($evalresult) || ($counter eq 3)) {
>                                 $evalresult = eval $evalcode;
>                                 $counter++;
>                         }
>                         $pageHash{"Retries"} = $counter if $counter > 1;
>                         $r->print($@) if $@;
>                         close (EVALFILE);
>
>I appreciate any and all constructive comments.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

__________________________________________________
Gunther Birznieks ([EMAIL PROTECTED])
eXtropia - The Web Technology Company
http://www.extropia.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to