View Single Post
  #4   (View Single Post)  
Old 16th February 2009
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by qsecofr View Post
Code:
# put some code inside $str
$str = '$c = $a + $b'; # Perl doesn't care what's inside $str
$a = 10; $b = 20;
eval $str;             # Treat $str as code, and execute it.
print $c;              # prints 30
Although I can only assume that you are responsible for the veracity of the code inserted into the database, it would still be prudent to check the value of $@ after the eval statement to ensure that the string executes without error.

Likewise, it is better to find out early that an error has occurred rather than wait until later when the culprit has been masked many times over.
Reply With Quote