Possible Duplicate:
What situations demand the use of eval() because there are no alternatives?
I've never used it. But I'm trying to build a case for/against it. When can legitimately be used because there is no better alternative. If you use eval() what do you do to use input?
...
Hello,
I have a array that I am writing to a file using var_export(). I reload the array every time the script starts. However, whenever I try to reference a variable inside the array it returns 'a', I can do a print_r() and see the array just fine, I just can not access the variable I want. Here is the saved output:
array (
'timesta...
Does anyone readily know if using eval() and responseText (using JSON) is faster or slower than just using responseXML?
I would imagine avoiding the eval() and using responseXML instead would be faster, despite the fact that you gotta write really long code to actually get the values of the XML.
Thanks.
...
Given the following definition of the LISP eval function - what is required to add the defmacro function? (Or even just evaluate a macro)
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))
(defun not. (x)
(cond (x '())
('t 't)))
(defun append. (x y)
(cond ((null. x) ...
I want to be able to define a block, and later evaluate that block from within a dynamically generated module/class. It seems like I could accomplish this somehow using eval and block.binding, but I haven't figured it out.
I have this as the base:
def define_module(name, &block)
name = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.g...
I seem to recall that it is not safe to trust the value of $@ after an eval. Something about a signal handler having a chance to set $@ before you see it or something. I am also too tired and lazy right now to track down the real reason. So, why is it not safe to trust $@?
...
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 assi...
For some years that I've been using my own PHP template engine, which is not really "my own" as I saw it on a tutorial many years ago. However, I've refactored most of the code making it simpler and easier to use. I rarely make a PHP project without it.
It's very basic and the class only has 3 methods, load, assign and render. The load ...
I am looking to assign objects in a loop. I've read that some form of eval(parse( is what I need to perform this, but I'm running into errors listing invalid text or no such file or directory. Below is sample code of generally what I'm attempting to do:
x <- array(seq(1,18,by=1),dim=c(3,2,3))
for (i in 1:length(x[1,1,])) {
eval(parse(...
Hi,
I've got a broken web service that I can't access and alter. It sends down some mainly nice JSON, but one of the attributes is a nested JSON object that is being sent down as a string.
http://www.ireland.com/api/getitemweb/185213
CustomJsonData in the response from the above url is the example.
My question is how could I interpret...
I need to call a jQuery function with EVAL (but I don't know how to do it), then I solve with this solution, but I don't think that this is the correct way...
<script>
jQuery.fn.customfunction = function (data) { alert( data ); }
</script>
<div id="eval_div"></div>
<form><input role="button" myFunction="customfunction"/></form>
<script...
Hi all,
I'm looking for an alternative to that code:
expl = eval "BeEF::Modules::Exploits::#{klass.capitalize}.new"
Here the eval is totally insecure. Is there an alternative I could use to generate dynamically classes without using eval? As in, klass is always different. So my code stays generic.
Thanks for your time.
...
The Program (115 Chars)
(defun rpn(e)(let((s()))(dolist(x e)(if(numberp x)(push x s)(push(eval(reverse(list(pop s)(pop s)x)))s)))(car s)))
A simple test:
CL-USER> (rpn '(1 2 3 * + 4 2 / +))
And it returns 9
Anyone has some good ideas about writing an Infix-to-RPN program inside one single tweet? I failed. I can wrote that one in 2...
Say I have a something like this:
<p id="script">$("p").css("color", "red");</p>
Is there a way to select the script contained within the tag and execute it using jQuery? In this case, the script
$("p").css("color", "red");
would be executed and then cause itself to be rendered with a red font color within the paragraph tag. I can...
How can I use eval in groovy to evaluate the following String:
{key1=keyval, key2=[listitem1, listitem2], key3=keyval2}
All the list items and keyval is a String.
doing Eval.me("{key1=keyval, key2=[listitem1, listitem2], key3=keyval2}") is giving me the following error:
Ambiguous expression could be either a parameterless closure exp...
my link button -
<asp:LinkButton runat="server" ID="lbtnEdit" Text="edit" OnClientClick="javascript:msgDisp('<%# Eval(LocationId).toString() %>')" />
and the javascript msgDisp is-
<script type="text/javascript" language="javascript">
function msgDisp(lid) {
alert(lid);
}
</script>
but it is not giiving ...
var input;
// method 1
input = document.getElementById('address').value;
alert(input)
// method 2
eval('input = "'+document.getElementById('address').value+'"')
alert(input)
method 1 is working fine, but method 2 is not working when newline characters are inputted and it says "unterminated string literal".
I need to store values usi...
Hi,
I have a YUI dialog that submits a form to a Java servlet. The servlet returns html and javascript. I take the response and put it into a div on the page and then eval the javascript that is within the div.
My problem is that I get an error in the firebug console saying "YAHOO is not defined" as soon as the servlet returns.
I do...
Let's say I have the following piece of code:
my $compiled = eval 'sub { print( "Hello World\n" ); }';
I can call this by writing:
$compiled->();
So far so good. Now imagine I create 10 functions:
my @fns = ();
for ( my $i = 0; $i < 10; $i++ ) {
push( @fns, eval "sub { print( 'I am function $i\n' ); }" );
}
I can call these 10...
<?php
$a = "a == a";
eval($a);
This returns false. I thought it's supposed to return true. Any thoughts/ideas why this is so.
...