in reply to Problem with Pattern matching and substitution using variables
my $data = '#define MANUFACTURER "xyz"'; my $replace = '#define MANUFACTURER(\s+)"xyz"'; my $replace_with = '"#define MANUFACTURER$1\"abcd\""'; $data =~ s/$replace/$replace_with/eeg; print $data;
See Search and replace in perlretut for a bit more detail. Note this should not be done if the data in $replace_with is at all untrustworthy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with Pattern matching and substitution using variables
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 |