Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re-Interpolating a Scalar (a string)

by Nichodemus (Initiate)
on Jul 29, 2005 at 18:28 UTC ( [id://479502]=note: print w/replies, xml ) Need Help??


in reply to Re-Interpolating a Scalar (a string)

Alright -- I am sorry to waste your time -- I have already figured it out!

$raw = '$parsed = "fred has $color eyes";'; eval $raw; print $parsed;


Sorry for the false alarm. :)

-Nich

Replies are listed 'Best First'.
Re^2: Re-Interpolating a Scalar (a string)
by friedo (Prior) on Jul 29, 2005 at 18:34 UTC
    While this will work fine, it's probably not a good idea. Especially if you don't know ahead of time what's going to be in $raw, any malicious code that gets put there will be evaled by your program. Further, string eval is quite slow from what I hear. Instead, I would highly reccomend using the hash lookup method provided by cmeyer above.
Re^2: Re-Interpolating a Scalar (a string)
by Joost (Canon) on Jul 29, 2005 at 18:33 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://479502]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found