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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
jasoncolsonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.