in reply to Advanced (or not) regular expression
Second, you need to be trickier. Here's one way:
It's a bit difficult to explain, but it's two layers of evaluation. The first layer turns qq{qq{$to}} into qq{our $1}, and the second layer interpolates $1.my $from = "my (mom)"; # UPDATE: was '"my (mom")' my $to = "our \$1"; $content =~ s/$from/qq{qq{$to}}/ee;
Or, you could use DynScalar:
It's magic.use DynScalar; my $from = "my (mom)"; my $to = dynamic { "our $1" }; $content =~ s/$from/$to/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Advanced (or not) regular expression
by kvale (Monsignor) on Apr 23, 2004 at 02:54 UTC |