Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: what difference between eval and do ?

by ikegami (Patriarch)
on Apr 19, 2018 at 20:14 UTC ( [id://1213191]=note: print w/replies, xml ) Need Help??


in reply to Re^3: what difference between eval and do ?
in thread what difference between eval and do ?

I didn't take the title literally. The OP appears to asking why do BLOCK and eval BLOCK behave differently in the provided code. I did not set to list all the difference between eval BLOCK and do BLOCK, at least one of which hasn't been mentioned yet (do BLOCK's interaction with the while statement modifier).

Replies are listed 'Best First'.
Re^5: what difference between eval and do ?
by Anonymous Monk on Apr 21, 2018 at 13:58 UTC
    But your code already perfectly show the difference and the underlining reason between eval and do: they both return the value of the last statement in the block, eval is sub-call, so it copy the last value and return it; and do is a bit like a named block. that's it.

      Nope, it only illustrates an inconsequential difference I didn't even know about before the OP posted it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found