Perl eval Function

Advertisements


Description

This function evaluates EXPR at execution time as if EXPR were a separate Perl script. This allows you to use a separate, perhaps user-supplied, piece of Perl script within your program. An eval EXPR statement is evaluated separately each time the function is called.

The second form evaluates BLOCK when the rest of the script is parsed (before execution).

Syntax

Following is the simple syntax for this function:

eval EXPR

eval BLOCK

Return Value

This function returns value of last evaluated statement in EXPR or BLOCK

Example

Following is the example code showing its basic usage:


When above code is executed, it produced following result:




Advertisements
Advertisements