in reply to tracing eval

The eval number changes quite often, but not the line number, so I thnk that means the same line of the same eval'ed code is failing.
Probably, yes.
How do I track down where the eval is happening?
You can use one of the routines from Carp which produce a stack trace. Attach either confess() or cluck() to $SIG{__WARN__} — the latter is fatal, the former a warning.
#!perl -w use Carp; local $SIG{__WARN__} = \&Carp::cluck; sub foo { my($x, $y) = @_; return eval '$x+$y'; } print foo(5); # should get 2 arguments;
Use of uninitialized value in addition (+) at (eval 1) line 1. eval '$x+$y ;' called at test.pl line 6 main::foo(5) called at test.pl line 8 5

p.s. For some reason unclear to me, I get no output using \&Carp::confess. Any hints on why are welcomed.

Replies are listed 'Best First'.
Re: Re: tracing eval
by jimc (Sexton) on Jan 13, 2003 at 15:05 UTC
    tiny nit - former, not latter. see perldoc Carp

    cluck - warn of errors with stack backtrace (not exported by default)
    confess - die of errors with stack backtrace