in reply to Re^2: eval something using private copy of variables
in thread eval something using private copy of variables
giving the resultuse threads; my $x=1; my $threads = threads->new(sub {eval '(++$x)+1'}); print "The value of \$x before eval is $x\n"; my $val = $threads->join(); print "The eval returned $val\n"; print "The value of \$x after eval is $x\n";
It seems like overkill, but then, you asked for it. Less expensive might be to copy that part of the symbol table that you want shared with the user, and restore it after they are done.The value of $x before eval is 1 The eval returned 3 The value of $x after eval is 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: eval something using private copy of variables
by gboole (Novice) on Aug 20, 2007 at 06:44 UTC |