[email protected] <> wrote:
> Hello,
>
> I have the following strings:
> TEST1=/bla/\${var1}/bla/${var2}a${var3}/bla
> TEST2=/bla/\${var1}/bla/${var2}${var3}/bla
>
> I want to transform them:
> TEST1=/bla/\$ENV{var1}/bla/$ENV{var2}a$ENV{var3}/bla
> TEST2=/bla/\$ENV{var1}/bla/$ENV{var2}$ENV{var3}/bla
>
> The rule: substitute all $var to $ENV{var}, but not if the character
> before $ is a \ (backslash).
>
> My solution works fine with TEST1 but not with TEST2:
> s/(^|[^\\]?)\$\{(\w+)\}/$1\$ENV\{$2\}/g;
> I get:
> TEST1=/bla/\$ENV{var1}/bla/$ENV{var2}a$ENV{var3}/bla
> TEST2=/bla/\$ENV{var1}/bla/$ENV{var2}{var3}/bla
Given your rule above, I would have said that neither worked. Surely,
\${var1} shouldn't have been changed.
>
> The problem occure, if no character is between two variables.
>
> Some ideas?
It would help a lot if you provided real code. Something that we could
cut & paste and run for ourselves.
HTH
--
Brian Raven
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs