Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: what difference between eval and do ?

by Eily (Monsignor)
on Apr 19, 2018 at 15:38 UTC ( [id://1213178]=note: print w/replies, xml ) Need Help??


in reply to what difference between eval and do ?

Another difference:

sub hello_do { do { return; }; print "Hello from hello_do\n"; } sub hello_eval { eval { return; }; print "Hello from hello_eval\n"; } hello_do(); hello_eval(); __DATA__ Hello from hello_eval
return is the return value of the eval itself, but the return value of the function calling do.

Replies are listed 'Best First'.
Re^2: what difference between eval and do ?
by Anonymous Monk on Apr 21, 2018 at 13:38 UTC
    As I replied before, That's because eval is a sub call, but do is a block. just image: s/eval/sub Foo/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-18 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found