Jano Svitok
5/14/2007 9:57:00 AM
On 5/14/07, Rebhan, Gilbert <Gilbert.Rebhan@huk-coburg.de> wrote:
>
>
> Hi,
>
> don't know if there's another | better way, but
> i solved it like that =
>
> yaml has now =
>
> replaceto1: "<Passwort><![CDATA["
> replaceto2: "]></Passwort>"
>
>
> and my script has =
>
> s=config['replaceto1']<<"#{@cvsreg}"<<config['replaceto2']
> [...]
> filesed!(config['replacefrom'],s,"#{file}")
Hi,
the #{} are evaluated when the string is instantiated, i.e. in normal
case when the line containing the literal (note: the LITERAL) is
evaluated. When you load the string from yaml, these #{} are not
evaluated at all.
What you might want to do is to add quotes around and call eval --
e.g. config['replaceto'] = eval("\"#{config['replaceto']}\""), with
all the dangerous implications of eval. (Note the double use of #{}...
once it is evaluated as the line is parsed to create another literal
that is then passed to eval to expand again. I could have avoided the
outer expansion by using "\"" + config[...] + "\"", but I guess this
one's faster), and it's shorter in any case.)