cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
How do I get perl to recognize the special variable in the $replace string?$string = "firstword secondword"; print "original: $string\n"; # doesn't work $search = '(second.+)'; $replace = '$1 thirdword'; ($varsub = $string) =~ s/$search/$replace/; print "variable substitution: $varsub\n"; # does work ($direct = $string) =~ s/(second.+)/$1 thirdword/; print "direct: $direct\n";
Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp variable substitution of special variable
by davido (Cardinal) on Jun 30, 2005 at 22:24 UTC | |
by cormanaz (Deacon) on Jul 01, 2005 at 00:23 UTC | |
|
Re: Regexp variable substitution of special variable
by diotalevi (Canon) on Jun 30, 2005 at 22:19 UTC | |
by Tanktalus (Canon) on Jul 01, 2005 at 18:01 UTC | |
by diotalevi (Canon) on Jul 01, 2005 at 21:09 UTC |