Is it possible to save some Perl code in a database, retrieve it using a select
statement, and execute that Perl code?
I have tried using eval, but that doesn't seem to work.
Here is what I'm trying right now and it doesn't seem to work:
my $temp = $qryResults[0];
print $temp . "\n";
eval{"$temp"};
The output is $con->Disc开发者_JS百科onnect();exit;
You just need:
eval $temp;
The reason your version didn't work was due to the block form of eval evaluating it as if you had written a simple string:
eval{"perl code here"}
It is like writing this line of Perl:
"Perl code here"
It isn't code; it's a string.
The block form evaluates what is inside the block. If a string is inside the block, it's just a string, not a script.
The string form evaluates what is inside the string.
I figured it out; if I remove the curly brackets then it works.
精彩评论