I have an array @a, in which i have 3 rows in the $a[0], 2 rows in $a[1] and $a[2] as shown below.

<th><rowspan=2>Target protein</th> <th><colspan=2>Purified protein concentration</th> <th><rowspan=3>Activity</th> <th>Mg/liter culture</th> <th>Mg/g dry cell weight</th> <th>Mg/liter culture</th> <th>Mg/g dry cell weight</th>

What i want to do is, if $a[0] has rowspan=2 then we have to place one empty <th></th> in the corresponding place of $a[1], likewise if rowspan=3 the we have to place empty <th></th> in $a[0] and $a[1] in corresponding place.

output: <th><rowspan=2>Target protein</th> <th><colspan=2>Purified protein concentration</th> <th><rowspan=3>Activity</th> <th></th> <th>Mg/liter culture</th> <th><rowspan=2>Mg/g dry cell weight</th> <th></th> <th>Mg/liter culture</th> <th>Mg/g dry cell weight</th> <th></th> <th></th>

I tried by splitting newline characters and by using the index value of the newarray i assigned the empty cell in the next $a[1]. But i could not able to get the correct solution. Is there any other way to do this.

20050426 Janitored by Corion: Fixed formatting and inline <th> tags


In reply to array manipulation by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.