develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000927.001] do and eval sometimes don't clear $@

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
September 28, 2000 08:43
Subject:
Re: [ID 20000927.001] do and eval sometimes don't clear $@
Message ID:
200009281541.IAA21494@smtp3.ActiveState.com
On Thu, 28 Sep 2000 12:24:49 BST, Simon Cozens wrote:
>On Wed, Sep 20, 2000 at 07:32:56PM -0400, Andrew Pimlott wrote:
>> The documentation for eval says
>>     If there was no error, C<$@> is guaranteed to be a null string.
>> and the documentation for do (the do EXPR form) says
>>         do 'stat.pl';
>>     is just like
>>         scalar eval `cat stat.pl`;
>
>Easy-peasy. Just clear the error SV when entering an eval or do:
>
>==== //depot/bleadperl/pp_ctl.c#3 - /home/simon/patchbay/bleadperl/pp_ctl.c ==
>==
>@@ -3013,6 +3013,7 @@
>     name = SvPV(sv, len);
>     if (!(name && len > 0 && *name))
> 	DIE(aTHX_ "Null filename used");
>+    sv_setsv(ERRSV, &PL_sv_no);
>     TAINT_PROPER("require");
>     if (PL_op->op_type == OP_REQUIRE &&
>       (svp = hv_fetch(GvHVn(PL_incgv), name, len, 0)) &&
>@@ -3291,6 +3292,7 @@
>     STRLEN len;
>     OP *ret;
> 
>+    sv_setsv(ERRSV, &PL_sv_no);
>     if (!SvPV(sv,len) || !len)
> 	RETPUSHUNDEF;
>     TAINT_PROPER("eval");

I think you're forgetting that there is only one $@.  (IOW, what about
DESTROY() or any of those other things done via call_sv(..., G_EVAL)
or eval_sv()?)

IIRC, the archives have some history on this issue.


Sarathy
gsar@ActiveState.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About