Substituting row in TABLE

In a function the first row of a TABLE should be deleted and add another row after the last one. How can I do this just once after a command given in order to avoid a looping?
Nikki_DorensAsked:
Who is Participating?
 
jasoncolsonConnect With a Mentor Commented:
Delete it?  After it's been written?  I would store all that information in a variable before outputing it as HTML.

First, you add the information you need to the string.  Let's call it $demo.

Next, lets split the string into Table Rows.

(@suffix) = split(/\<TR\>/,$demo)

So now, you have:

@suffix[0] = <TABLE>
@suffix[1] = <TD>cell1a</TD>
             <TD>cell1b</TD>
             <TD>cell1c</TD>
             </TR>
@suffix[2] = <TD>cell2a</TD>
             <TD>cell2b</TD>
             <TD>cell2c</TD>
             </TR>

etc.

so now, you create a new $output string that contains @suffix[0]+@suffix[2]+etc. Split your last string in the same way with:

$numsuffixes = @suffix;
$end = split(/\<\/TABLE\>/,@suffix[$numsuffixes]);
$output = $end+$newrow+"</table>";

Now output this to HTML
hope this helps!
0
 
thoellriCommented:
And TABLE is what? An array? a hash? a string? a table in a database?
0
 
jasoncolsonCommented:
This seems waaaaay too simple.  I must not understand the question.  On the off chance it is this simple here's what I'd do:

$tablehasbeendeleted = 0;
while ($tablehasbeendelete == 0) {&arfarf;}

sub arfarf
{
&deletetable;
if ($successful {$indeletingtable}($tablehasbeendeleted = 1;)
}


or place an if statement at the beginning of arfarf.
0
 
Nikki_DorensAuthor Commented:
I think I did not explain correctly what I need; the TABLE i meant is the HTML type.
In a table like:
<TABLE>
<TR>
<TD>cell1a</TD>
<TD>cell1b</TD>
<TD>cell1c</TD>
</TR>
<TR>
<TD>cell2a</TD>
<TD>cell2b</TD>
<TD>cell2c</TD>
</TR>
<TR>
<TD>cell3a</TD>
<TD>cell3b</TD>
<TD>cell3c</TD>
</TR>
</TABLE>
I need to delete from the first occurrence of <TR> to the first </TR> and add at the end, before </TABLE>:
<TR>
<TD>cell4a</TD>
<TD>cell4b</TD>
<TD>cell4c</TD>
</TR>
0
All Courses

From novice to tech pro — start learning today.