in reply to Determining depth of eval nesting

The caller function might be you best bet. It can be used to examine the call stack. Nested evals have '(eval)' as the subroutine name:
#!/usr/bin/perl use strict; use warnings; sub eval_depth { my $eval_depth = 0; my $frame = 0; while (my @caller_info = caller($frame++)) { if ($caller_info[3] eq '(eval)') { $eval_depth++; } } return $eval_depth; } print "no evals: ".eval_depth()."\n"; eval 'print "one eval :".eval_depth()."\n"'; eval q{ eval 'print "two evals:".eval_depth()."\n"'};

Replies are listed 'Best First'.
Re^2: Determining depth of eval nesting
by aufflick (Deacon) on Apr 12, 2007 at 05:56 UTC
    Sorry for the late reply - been on hols.

    ++ This worked a charm - I figured it could be gotten from caller() but I didn't expect it to be this easy.