eval
eval
eval EXPR
eval BLOCK
eval
In the first form, often referred to as a "string eval", the return value of EXPR is parsed and executed as if it were a little Perl program. The value of the expression (which is itself determined within scalar context) is first parsed, and if there were no errors, executed as a block within the lexical context of the current Perl program. This means, that in particular, any outer lexical variables are visible to it, and any package variable settings or subroutine and format definitions remain afterwards.
Note that the value is parsed every time the eval
executes- If EXPR is omitted, evaluates $_
. This form is typically used to delay parsing and subsequent execution of the text of EXPR until run time.