in reply to Using sub-matches to interpolate hash keys (array indices)?
I realize this doesn't answer the question directly, but would building the regex dynamically be an option?
my @a = qw/a d/; my $re = join '|', map { $_.quotemeta($a[$_]) } 0..$#a; print $re, "\n"; $_ = '0a1d1y0z'; print s/($re)/xx/g, "\n"; print $_, "\n"; __END__ 0a|1d 2 xxxx1y0z
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using sub-matches to interpolate hash keys (array indices)?
by vr (Curate) on Jul 21, 2015 at 16:17 UTC |