ims.analyst
11-21-2005, 02:01 PM
Hi All,
I am a newbie at perl and I am facing a problem which I can not resolve. I have tried to find the answer, but have been unsuccessful in finding any answer anywhere.
Code Excerpt #1:
$line =~ s/(<field name=)"myfieldname"(.*?)(\/>)/$1 "newNameValue" $2 bLogged="true" $3/g;
Code Excerpt #2:
$findString = "(<field name=)\"myfieldname\"(\.\*\?)(\/>)";
$replaceString = "\$1 \"newNameValue\" \$2 bLogged=\"true\" \$3";
$line =~ s/$findString/$replaceString/g;
#1. Works beautifully and replaces the string the way I want.
However,
#2.does not evaluate $1, $2, $3 and replaces the string with these values, meaning: the string is replaced with:
$1 "newNameValue"$2 bLogged="true" $3
I have tried everything to evaluate these values, but nothing seems to work. Any help is really appreciated.
Thanks in advance,
Ims.
I am a newbie at perl and I am facing a problem which I can not resolve. I have tried to find the answer, but have been unsuccessful in finding any answer anywhere.
Code Excerpt #1:
$line =~ s/(<field name=)"myfieldname"(.*?)(\/>)/$1 "newNameValue" $2 bLogged="true" $3/g;
Code Excerpt #2:
$findString = "(<field name=)\"myfieldname\"(\.\*\?)(\/>)";
$replaceString = "\$1 \"newNameValue\" \$2 bLogged=\"true\" \$3";
$line =~ s/$findString/$replaceString/g;
#1. Works beautifully and replaces the string the way I want.
However,
#2.does not evaluate $1, $2, $3 and replaces the string with these values, meaning: the string is replaced with:
$1 "newNameValue"$2 bLogged="true" $3
I have tried everything to evaluate these values, but nothing seems to work. Any help is really appreciated.
Thanks in advance,
Ims.