eval

What is Dynamic Code Evaluation as mentioned by John Resig

佐手、 提交于 2019-12-12 15:49:38
问题 In his book "Secrets of the Javascript Ninja", John Resig writes: Although dynamic code evaluation has been maligned due to its complexity and potential for security issues, without it we wouldn’t have had the CoffeeScript programming language. I was hoping that someone could explain what is Dynamic Code Evaluation? Also, are there any code examples (or word examples) that would help better explain it? Furthermore, are there any website examples that use dynamic code evaluation? Also, if

Can I write this macro without using eval?

邮差的信 提交于 2019-12-12 13:07:29
问题 I'm trying to write a macro which will catch a compile time error in Clojure. Specifically, I would like to catch exceptions thrown when a protocol method, which has not been implemented for that datatype, is called and clojure.lang.Compiler$CompilerException is thrown. So far I have: (defmacro catch-compiler-error [body] (try (eval body) (catch Exception e e))) But of course, I've been told that eval is evil and that you don't typically need to use it. Is there a way to implement this

Eval math formula string with ActionScript

谁说胖子不能爱 提交于 2019-12-12 11:39:49
问题 How can I eval Math formulas with AS3? Nothing fancy, things like (10/3)*4+10 . Thanks. 回答1: While you could use a huge eval lib like D.eval or AS3Eval, all you really need is something like this simple MathParser (More info about the MathParser) Here's how you'd use the MathParser: package { import bkde.as3.parsers.*; import flash.display.Sprite; public class MathTest extends Sprite { public function MathTest() { var parser:MathParser = new MathParser([]); var compiledObj:CompiledObject =

PHP - Check PHP Code for Syntax Errors without running the code

☆樱花仙子☆ 提交于 2019-12-12 11:06:09
问题 I know that by using eval($code_to_check); we can check if this value equals FALSE and if so, we can stop execution of the script. However, the problem I'm facing is that I am unable to define a function, because it gets called twice... it gets processed with the eval() check to be sure there are no syntax errors and than processes the function again, but shows an error that states that it can NOT REDECLARE this function, as it is already being declared in the eval'd function. How can I make

Can a Perl system() call ever die?

戏子无情 提交于 2019-12-12 10:36:27
问题 Can a system() call can ever die in Perl 5? (in other words, in order to 100% crash-proof a program that does a system() call, does it need to be wrapped into an eval block , or is that wholly totally unnecessary?) I haven't found a single mention to that possibility in perldoc system, but didn't quite find the precise "this call never dies" either. NOTE: the question is about basic CORE Perl here, no autodie or any other custom module that would have similar effect. Also, assume no ALRM

Laravel - syntax error, unexpected end of file

只谈情不闲聊 提交于 2019-12-12 10:29:10
问题 I have a website which works fine on host, but I'm currently trying to install it on localhost. I've downloaded everything and configured to work on localhost - Database & URL. The problem is this error: Unhandled Exception Message: syntax error, unexpected end of file Location: C:\Program Files (x86)\EasyPHP-12.1\www\laravel\view.php(386) : eval()'d code on line 118 And I don't know what causes it. Any solutions? P.S. I've setup in my windows' host file 127.0.0.1 myproject.dev . 回答1: There

How can I de-obfuscate or decode this Perl code?

人盡茶涼 提交于 2019-12-12 10:06:13
问题 I found this code and I think it's encoded. I tried to understand how it's encoded or how can read it. Does anyone have an idea to decode this code? #!/usr/bin/perl eval unpack u=>q{_<')I;G0@(EQN7&5<>#5"7'@S,UQX,S-<>#9$7'@U-UQX-C%<>#<R7'@V15QX-CE<>#9%7'@V-UQX,C!<>#4Y_7'@V1EQX-S5<>#(P7'@T1%QX-C%<>#<Y7'@R,%QX-$5<>#8U7'@V-5QX-C1<>#(P7'@U-%QX-D9<>#(P7'@T_.5QX-D5<>#<S7'@W-%QX-C%<>#9#7'@V0UQX,C!<>#<S7'@V1EQX-D1<>#8U7'@P05QX,C!<>#(P7'@R,%QX_,C!<>#(P7'@R,%QX,C!<>#(P7'@R,%QX-$1<>#9&7'@V-%QX-S5<>#9#7'

How to dynamically set array keys in php

放肆的年华 提交于 2019-12-12 08:37:17
问题 I have some logic that is being used to sort data but depending on the user input the data is grouped differently. Right now I have five different functions that contain the same logic but different groupings. Is there a way to combine these functions and dynamically set a value that will group properly. Within the function these assignments are happening For example, sometimes I store the calculations simply by: $calcs[$meter['UnitType']['name']] = ... but other times need a more specific

Does converting json to dict with eval a good choice?

≯℡__Kan透↙ 提交于 2019-12-12 08:31:28
问题 I am getting a json object from a remote server, and converting it to a python string like this: a = eval(response) Is this stupid in any way, or do I have a better option? 回答1: Using eval is not a good way to process JSON: JSON isn't even valid Python, because of true , false , and null . eval will execute arbitrary Python code, so you are at the mercy of malicious injection of code. Use the json module available in the standard library instead: import json data = json.loads("[1, 2, 3]") If

Difference between eval and backticks (reverse apostrophe)

耗尽温柔 提交于 2019-12-12 08:15:39
问题 Can anyone tell me what the big difference here is and why the latter doesn't work? test="ls -l" Both now work fine: eval $test echo `$test` But in this case: test="ls -l >> test.log" eval $test echo `$test` The latter will not work. Why is that? I know that eval is just executing a script while the apostrophes are executing it and return the result as a string. What makes it not possible to use >> or simmilar stuff inside the command to execute? Maybe is there a way to make it work with