shtihskar has asked for the wisdom of the Perl Monks concerning the following question:
my $data = '#define MANUFACTURER "xyz"'; my $replace = '#define MANUFACTURER(\s+)"xyz"'; my $replace_with = '#define MANUFACTURER$1"abcd"'; $data =~ s/$replace/$replace_with/g;; print $data;
Expected Output is : #define MANUFACTURER "abcd" (with appropriate number of spaces)
But the output that i am geting is: #define MANUFACTURER$1"abcd"
In the actual usage scenario, variables $data, $replace and $replace_with are read from a file. How to get the expected output?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Pattern matching and substitution using variables
by kennethk (Abbot) on Sep 09, 2011 at 17:04 UTC | |
by Kc12349 (Monk) on Sep 09, 2011 at 18:42 UTC | |
by kennethk (Abbot) on Sep 09, 2011 at 19:34 UTC | |
by shtihskar (Initiate) on Sep 12, 2011 at 08:27 UTC |