in reply to Eval str return different from Eval block return

Addendum:

podmaster points out that the last example will choke under strict. However on my machine replacing it with Zaxos suggestion

print "Str Eval ret :",readonly((eval'capture(5)')->[0]);
Makes strict happy, but the bug remains (at least on my system.)
use strict; sub capture {\@_}; sub readonly{ my $v=$_[0]; eval{$_[0]=$v;1} ? 0 : 1 } $\="\n"; print "No eval :",readonly(capture(5)->[0]); eval ' print "In str eval :",readonly(capture(5)->[0]); '; eval { print "In block eval :",readonly(capture(5)->[0]); }; print "Block Eval ret :",readonly(eval{capture(5)}->[0]); print "Str Eval ret :",readonly((eval'capture(5)')->[0]); __END__ No eval :1 In str eval :1 In block eval :1 Block Eval ret :1 Str Eval ret :0

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

Replies are listed 'Best First'.
Re: Re: Eval str return different from Eval block return
by Dog and Pony (Priest) on May 17, 2002 at 09:48 UTC
    Here is an extra test case - this one also returns correctly:
    print "Eval all:",eval'readonly(capture(5)->[0])';

    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.