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

AFAIK the eval counter begins at 1 and increments by 1 in the order of compilation, so you should be able to find the block in question easily enough by looking at the order in which they are compiled. You might also store the code snippets in their text form inside an array starting at index 1. The real question though is why you're storing the code in raw text? Why can't you place those subroutines in another file that you require? Also, unless you have strict control over what gets submitted to you in the form of text files, you may want to run this eval'd code inside a Safe.


"The dead do not recognize context" -- Kai, Lexx
  • Comment on Re: Re: Re: Is it possible to determine the eval block accumulator?

Replies are listed 'Best First'.
Re: Is it possible to determine the eval block accumulator?
by Abigail-II (Bishop) on Feb 14, 2003 at 11:58 UTC
    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

      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