in reply to Determining depth of eval nesting
You might be able to derive the info by some judicious parsing of the return of caller and assignments to a (relatively) globals scoped variable:
eval qq[ print "1:$^S"; print caller(); eval q[ print "2:$^S"; print caller(); eval q/ print "3:$^S"; print caller(); / ] ];; 1:1 main (eval 55) 1 2:1 main (eval 56) 1 3:1 main (eval 57) 1
The "subname" element in the caller return text seems to reliably indicate the number of evals entered. By parsing and storing the current value prior to entering and eval, it would give you a rough guide.
It wouldn't distinguish between a 3rd level of nested eval, and the second of two evals serially nested within an outer one though.
Maybe you could override CORE::GLOBAL::eval and institute your own depth counter?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Determining depth of eval nesting
by ferreira (Chaplain) on Apr 03, 2007 at 18:58 UTC | |
by diotalevi (Canon) on Apr 04, 2007 at 03:20 UTC |