in reply to Re: Re: Re: Is it possible to determine the eval block accumulator?
in thread Is it possible to determine the eval block accumulator?

But the order in which the strings are compiled is of course determined at *run* time. If you see something of the form Died at (eval NNN), it means the N'th time (string) eval was called. This doesn't have much resemblence with the N'th occurance of eval in the code.

Just try:

perl -wle 'for (1 .. 10) {eval "die"; print $@}'

Abigail

Replies are listed 'Best First'.
Re: Re: Is it possible to determine the eval block accumulator?
by djantzen (Priest) on Feb 14, 2003 at 12:44 UTC

    Perhaps I'm just overtired here, but my understanding is that what the OP is talking about is loading code into subroutines *once*, not eval'ing the same string over and over again, in which case those numbers will be static.

    my $sub = eval q(sub { die }); for (1..10) { eval { $sub->() }; print "$@\n"; }

    "The dead do not recognize context" -- Kai, Lexx
      Yeah, sure. But if the subroutines are to be found in file(s), would you write a different eval for each of them? Or would you use a loop or a subroutine to do the work?

      I know what I would do.

      Abigail

        What does "OP" mean?

        Essentially, when the mod_perl server starts up it parses a set of files that can dynamically change between server restarts. The initaliziation script then parses the files creating code segments which it then expression evals once to check that the code is a) valid and b) if it is returns the coderef to the compiled code.

        If the code did not generate any *syntax* errors then I store the coderef in a hash for further usage by my content engine, if it failed then the error is stored instead of a coderef.

        The basic premise here is that the code pieces being stored are APIs to be used by my content engine, parsing the files and storing the API code snippets as coderefs allows quick and easy access to the compiled code.

        The solution provided by Abigail below simply helps me find out where a non-syntax error occured when all the info I get is the "eval xxx" in the error log.

        Hopefully this is making more sense now, for an example of the project this is running on check out http://beta.dereth.ac/ which is one of the sites currently running on my engine. :)