rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a markup file, in which there is a element like <ins cnt="#">. Every time I encounter this element, it has to be replaced with <TAG>, the number of times specified in the attribute.
For example, if the tag is <ins cnt="4">, the output file should have <TAG><TAG><TAG><TAG>. This ins appears several times in the input file. I am reading through the file and used a for loop as:
$file =~ /<ins cnt="([^>]+)">/g;
for ($x=0; $x != $1; $x++) {
print F2 <TAG>;
}
But this is not producing the result I needed. Can anyone help me with a syntax/logic for this replacement
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recursive insertion of tags
by gellyfish (Monsignor) on Jul 20, 2006 at 11:05 UTC | |
|
Re: Recursive insertion of tags
by swkronenfeld (Hermit) on Jul 20, 2006 at 14:52 UTC |