in reply to Another question about expanding variables in text strings
Second, if you are using use strict; (recommended) and variables declared with 'my', you need to use the approach for lexicals given on the page you mention:
This assumes all the interpolated values are array values. If that is not the case, a different approach will be needed in the first half of the regex. Perhaps something like: s/(\$[a-zA-Z0-9[\]]+)/$1/gee which also works with the example data you gave.my @Val = qw(aaa bbb ccc); my $str = 'TESTDATA_BETA$Val[1]_DEFL$Val[2].$Val[0]'; if ($str =~ s/(\$[^]]+\])/$1/gee) { print "$str\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Another question about expanding variables in text strings
by tye (Sage) on Mar 15, 2001 at 04:51 UTC | |
|
Re: Re: Another question about expanding variables in text strings
by Anonymous Monk on Mar 24, 2001 at 03:07 UTC |