in reply to Why no $@ after eval? Bug?
They do not produce different results. Look:
$ perl -e 'eval { map { $_++ } 1 };' $ perl -e 'eval { map { $_++ } 1 }; print $@;' Modification of a read-only value attempted at -e line 1. $ perl -e ' map { $_++ } 1 ' Modification of a read-only value attempted at -e line 1.
In the first attempt, you have your code in an eval block, so the error is stored in $@.
Now, why isn't it getting printed?
I'm assuming it's because rmap evaluates the code it is being handed my @got = eval { $self->call(); }; so it is overwriting the value of $@ and thus when your eval block gets out it doesn't print the error message. I would assume that calling evals inside of eval could get messy.
Someone cares to elaborate about eval inside of eval? for example, why doesn't this:
print out "1: Died at (eval 1) line 1." ?$ perl -e '$n = q/eval { die;}; print "1: $@"/; eval {$n}; print "2: $ +@"'
He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
Chady | http://chady.net/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Why no $@ after eval? Bug?
by hv (Prior) on May 07, 2004 at 11:26 UTC |
In Section
Seekers of Perl Wisdom