s/\$ENV{(\w+)}/$ENV{$1}/ge;
That doesn't solve the 'problem' of wanting to have a literal '$ENV{X}' kept unchanged for some reason. That seems unlikely enough of a desire that I'm not sure I'd even do anything about it. Though I might prevent substitution if no such environment var is set:
s/\$ENV{(\w+)}/ exists $ENV{$1} ? $ENV{$1} : "\$ENV{$1}" /ge;
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What's the best way to convert a non interpolated single-quoted string into an interpolated double-quoted string? (smor)
by emilbarton (Scribe) on Mar 15, 2012 at 20:25 UTC |