podmaster points out that the last example will choke under strict. However on my machine replacing it with Zaxos suggestion
Makes strict happy, but the bug remains (at least on my system.)print "Str Eval ret :",readonly((eval'capture(5)')->[0]);
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.
In reply to Re: Eval str return different from Eval block return
by demerphq
in thread Eval str return different from Eval block return
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |