Eval

Updated: 11/16/2019 by Computer Hope

An 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 many abilities depending on your programming language. For example, in Perl, PHP (PHP: Hypertext Preprocessor), and JavaScript, the eval command can interpret and execute a variable string as code.

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. With a shell, eval is a builtin command of the Bash shell. See our eval command page for further information.

Compare, Computer abbreviations, Programming terms