in reply to How to do that with eval ?

In general, if you have problems with eval, make sure you print the error message in $@ if the eval fails along with the string you are evaling; that will usually help pinpoint the error.

In designing the code in the first place, instead of randomly tossing together "" or '' and $variables, decide what you want the evaled code to look like for given input and then write the code to produce that string, paying attention to the different interpolation rules of '' or "".