I would like to search and replace an xml file with the ini content, but i am getting incorrect answer in my bb.xml with the same regular expression syntax without replacement.
My ini file
-----------
myPara para
lPara last_para
<mySeca>([0-9]+). <sec id=\"$1\">
My XML file.
-----------
my perl part
--------------
output bb.xml
------------
Can anyone help me to solve this
My ini file
-----------
myPara para
lPara last_para
<mySeca>([0-9]+). <sec id=\"$1\">
My XML file.
-----------
Code:
<myPara>dsa fhasdjkh fjaksdhkjfh asjkdhfjk lashdkjfh ajksdhf jkasdhfjka sd</myPara> <lPara>asdfh asgdhfgsdf asdhf asdhgf asd</lPara> <mySeca>1. asdfgashdgfhasdghfg sdhfg asd</mySeca>
--------------
Code:
$filename = "c:\\temp\\temp\\F&R.ini"; my $raw="c:\\temp\\temp\\aa.xml"; my $output="c:\\temp\\temp\\bb.xml"; open ($FIN,$raw) or die "Could not read from $raw, program halting."; my $instr; while (my $lines=<$FIN>) { $instr.=$lines.""; } open(FILE, $filename) or die "Could not read from $filename, program halting."; $count = 1; while (<FILE>) { chomp($_); my($find,$replace)=split(/\t/,$_,2); $instr=~s/$find/sub{$replace}->()/gei; count++; } open(FOUT,">$output"); print FOUT $instr; close FOUT;
------------
Code:
<para>dsa fhasdjkh fjaksdhkjfh asjkdhfjk lashdkjfh ajksdhf jkasdhfjka sd</para> <last_para>asdfh asgdhfgsdf asdhf asdhgf asd</last_para> <sec id=\"$1\">asdfgashdgfhasdghfg sdhfg asd</mySeca>