You might want to save the the current table number in @save as well,
to be able to handle tables that have both other tables and text inside.
To do this, you could apply these changes:
At the top:
my $tablenr=0;
In _start:
if ($tag eq 'table'){
push @save, [$tablenr,$row,$column];
$row = $column = 0;
$tablenr=$count;
++$count;
$in_table++;
}
In _end:
if ($tag eq 'table') {
($tablenr, $row, $column) = @{ pop @save };
--$in_table;
}
In Text:
$table[$tablenr][$row][$column] .= $text if ($in_table) && ($text !~ m
+/^\s+$/);
You might want to add an initialization of @save as well, to avoid trying to der
eference an undefined value when you leave a toplevel table.
Something like this perhaps:
my @save=([]); #initialize with an empty list as first element.
Regards,
GoldClaw
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.