Runtime evaluation: Difference between revisions

Content added Content deleted
Line 238: Line 238:
=={{header|Perl}}==
=={{header|Perl}}==


Any expression can be passed to <code>eval</code>, in run-time the expression is parsed and executed in the same scope as it was called so any variables declared are visible in the <code>eval</code> and variables declared inside the eval still exist afterwards, you can use the <code>return</code> statement to exit the <code>eval</code> returning a value, if omitted, the result of the last expression evaluated will be returned.
Any expression can be passed to [http://perldoc.perl.org/functions/eval.html eval], in run-time the expression is parsed and executed in the same scope as it was called so any variables declared are visible in the <code>eval</code> and variables declared inside the eval still exist afterwards, you can use the <code>return</code> statement to exit the <code>eval</code> returning a value, if omitted, the result of the last expression evaluated will be returned.


<lang perl>($a, $b) = (5, 7);
<lang perl>($a, $b) = (5, 7);