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]