rsriram has asked for the wisdom of the Perl Monks concerning the following question:
The program line for that is:
$_ =~ s/<csp c="(\d+)">/"<colspec colnum=\"1\" colname=\"col1\"\/>" x $1/egs;
This is working fine, but I need the number mentioned in colnum and colname needs to be incremented by one everytime. If I use a variable and increase it by one with the following code, I am not getting the numbers.
$_ =~ s/<csp c="(\d+)">/"<colspec colnum=\"$num\" colname=\"col$num++\"\/>" x $1/egs;
To be more precise, if the input is <csp c="3">, the output should be:
<colspec colnum="1" colname="col1"/> <colspec colnum="2" colname="col2"/> <colspec colnum="3" colname="col3"/>
Could anyone help me please?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Making multiple replaces through Regex
by sathiya.sw (Monk) on Nov 27, 2008 at 06:46 UTC | |
|
Re: Making multiple replaces through Regex
by prasadbabu (Prior) on Nov 27, 2008 at 06:15 UTC | |
by rsriram (Hermit) on Nov 27, 2008 at 06:18 UTC | |
|
Re: Making multiple replaces through Regex
by parv (Parson) on Nov 27, 2008 at 06:55 UTC | |
|
Re: Making multiple replaces through Regex
by jwkrahn (Abbot) on Nov 27, 2008 at 07:06 UTC | |
|
Re: Making multiple replaces through Regex
by Punitha (Priest) on Nov 27, 2008 at 06:23 UTC |