From: Kaspar Schiess Date: 2004-07-04T18:49:17+09:00 Subject: Re: Problem with "eval" -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dirk Einecke wrote: | Hi. | | I've a id and a value. Now I want a variable with id as name and the | content from value as value of this variable. I tryed like this: | | id = 'foo' | value = 'This is the value.' | eval "$#{id} + ' = ' + #{value}" # -> $id = 'This is the value.' | | But this is not working. What's wrong? Is there a better/faster way? | | greetings | Dirk Einecke | | Hello Dirk, ~ eval %Q{ $#{id} = #{value.inspect} } will work for value being string values (and some others).. And you will probably get to hear that this is insecure and has numerous problems. Setting these variables as elements of a hash or open struct is better design - of course your mileage may vary. (If you are not told by others here, you might have a look at why PHP does not do auto-creation of global variables anymore..) kaspar semantics & semiotics code manufacture www.tua.ch/ruby -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFA59PAFifl4CA0ImQRAphrAJ9483uwSTphc2i5O2rNDi8rZJUVjgCeIrbk 0YjXKZBjXX/akDS8+Pegg4g= =QV4D -----END PGP SIGNATURE-----