in reply to Re: why did i die?
in thread why did i die?
The difference (in my opinion) would be between
eval 1/0 # compile-time error
and
my $d= 0; eval 1/$d;
Maybe that would be a solution to discern between compile- and runtime-errors - wrap the code in question in a subroutine. If the code compiles, then we don't have a compile-time error:
my $code; my $ok= eval sprintf q{ $code= sub { %s }; 1 }, $string; if(! $ok) { my $err= $@; warn "Compile error on $string: $err"; }; $ok= eval { $code->(); 1; }; if( ! $ok) { my $err= $@; warn "Runtime error on $string: $err"; };
Update: Upon testing, I now realize that 1/0 does not generate a compile-time error. But at least, that way one could find out whether there is a compile-time error or a runtime error.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: why did i die?
by markov (Scribe) on Apr 02, 2014 at 09:38 UTC |