NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: Evaluating strings as variables ?
by Rich36 (Chaplain) on Apr 17, 2002 at 13:44 UTC

    You could try this node from tye - (tye)Re: Interpolating variables from a file. Helped me a great deal with something similiar - I needed to store variable names (i.e. $foo) in a file then interpolate them as variables in the code.


    Rich36
    There's more than one way to screw it up...

Re: Evaluating strings as variables ?
by Fletch (Bishop) on Apr 17, 2002 at 15:03 UTC

    Be aware that if you're not very sure of the source of the values comming back from your database you're treading in dangerous waters. If a malicious entity can get their own values in there somehow, th3y wI11 0wN J00 (especially since it looks like you're subsequently planning on passing values to system()).

    It's better practice to keep your code and data seperate (c.f. use strict "refs" :). Perhaps create different modules implementing an interface, and then use data from your database to select from that (limited, controlled) set of modules.

Re: Evaluating strings as variables ?
by kappa (Chaplain) on Apr 17, 2002 at 15:12 UTC
    You pronounced the keyword: evaluate. Use eval().