Eval
Updated: 11/16/2019 by Computer Hope
A eval may refer to any of the following:
1. Short for evaluate, eval is a function in different interpreted and compiled programming languages. This function can have a variety of different abilities depending on the programming language you're using. For example, in Perl, PHP, and JavaScript the eval command can interpret a variable string as code and execute it.
Example of eval in Perl
my $one = 1; my $two = 2; my $total = 0; my $example = '$total = $one + $two'; eval $example; print $total;
In the above example, the string stored in the $example variable is executed using the eval command. A programmer could take this expression further by executing a complete Perl program stored in another file.
2. When referring to a shell, eval is a builtin command of the Bash shell. See our eval command page for further information.