rsriram has asked for the wisdom of the Perl Monks concerning the following question:
hi, I am writing a perl script to code a text file to XML. A line which replaces a particular tag goes like,
$_ =~ s/<CT>/<section id=\"ch$acnofm\" label=\"\" xreflabel=\"\" role=\"fm\">/g;
I have stored the chapter number in $acno, the output should look like
<section id="ch01fm" label="" xreflabel="" role="fm">
Because the static text 'fm' immediately follows a variable $acno, perl considers $acnofm as a single variable and because $acnofm does not have any value assigned to it, the replacement is made as:
<section id="ch" label="" xreflabel="" role="fm">
Could anyone help me with the syntax for this replace?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Replacing a string with a memory variable
by BrowserUk (Patriarch) on Jun 28, 2006 at 11:34 UTC | |
Re: Replacing a string with a memory variable
by mickeyn (Priest) on Jun 28, 2006 at 12:11 UTC | |
Re: Replacing a string with a memory variable
by VSarkiss (Monsignor) on Jun 28, 2006 at 14:08 UTC |