Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Eval str return different from Eval block return

by demerphq (Chancellor)
on May 17, 2002 at 09:47 UTC ( #167250=note: print w/ replies, xml ) Need Help??


in reply to Re: Eval str return different from Eval block return
in thread Eval str return different from Eval block return

Which OS and Perl version Zaxo? I still get incorrect results

use strict; use warnings; 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]); print "Str Eval ret2 :",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 Str Eval ret2 :0

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


Comment on Re: Re: Eval str return different from Eval block return
Download Code
Replies are listed 'Best First'.
Re: Re: Re: Eval str return different from Eval block return
by astaines (Curate) on May 17, 2002 at 11:53 UTC

    On Win NT and AS perl 5.6.1 you get

    --<br> No eval :1 In str eval :1 In block eval :1 Block Eval ret :1 Str Eval ret :0 Str Eval ret2 :0 --
    Anthony Staines

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://167250]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (16)
As of 2015-07-29 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls