http://www.perlmonks.org?node_id=889106


in reply to What is the difference between eval and do?

Note: I wrote this and only after realized that I didn't read eliya's answer carefully enough. Consider this an amplification of his final paragraph.

There is a very nice summary of the difference in the documentation for do - see the second example for do EXPR.

One of the biggest differences is that the code run by eval can "see" the value of my variables in the code surrounding it. When do "some file" executes the code in a file, that code lives in its own world and cannot access those variables.

Replies are listed 'Best First'.
Re^2: What is the difference between eval and do?
by AGhoulDoingPerl (Sexton) on Feb 20, 2011 at 05:41 UTC
    and this too, thanks:)