Example:
$expression, $true and $false are all dynamic. This code will be used in a web-environment so eval($expression) is a very bad way to do it.my $output; my $expression = "5 < 7"; my $true = "String displayed if true"; my $false = "String displayed if false"; if (eval($expression)) { $output = $true; } else { $output = $false; } print $output;
Is there a secure way to evaluate $expression without use of eval ?
In reply to securely evaluating an expression by Len
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |