Not surprisingly, the problem turned out to be a simple one.  I was
using strict on the module that ran the eval.  The code that was being
eval'ed didn't throw an error (nothing in $@) but it did show the 
warnings in the error log.  Sorry to trouble you, and thanks for the 
responses that I did get.

David Hill 





-----Original Message-----
From: Ed Park [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 07, 2000 3:08 AM
To: Hill, David T - Belo Corporate; [EMAIL PROTECTED]
Subject: RE: eval statements in mod_perl


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


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]

Reply via email to