Here's something I did for https://www.rosettacode.org/wiki/Display_an_outline_as_a_nested_table#Perl It's not exactly what I think you want, but it may be close.

#!/usr/bin/perl # http://www.rosettacode.org/wiki/Display_an_outline_as_a_nested_table use strict; use warnings; my @rows; my $row = -1; my $width = 0; my $color = 0; our $bg = 'e0ffe0'; parseoutline( do { local $/; <DATA> =~ s/\t/ /gr } ); print "<table border=1 cellspacing=0>\n"; for ( @rows ) { my $start = 0; print " <tr>\n"; for ( @$_ ) # columns { my ($data, $col, $span, $bg) = @$_; print " <td></td>\n" x ( $col - $start ), " <td colspan=$span align=center bgcolor=#$bg> $data </td>\n" +; $start = $col + $span; } print " <td></td>\n" x ( $width - $start ), " </tr>\n"; } print "</table>\n"; sub parseoutline { ++$row; while( $_[0] =~ /^( *)(.*)\n((?:\1 .*\n)*)/gm ) { my ($head, $body, $col) = ($2, $3, $width); $row == 1 and local $bg = qw( ffffe0 ffe0e0 )[ $color ^= 1]; if( length $body ) { parseoutline( $body ) } else { ++$width } push @{ $rows[$row] }, [ $head, $col, $width - $col, $bg ]; } --$row; } __DATA__ insects large wings butterfly small or no wings very long rear legs antenna front mosquito antenna rear grasshopper shorter rear legs horned head rhino beetle not horned head small eyes termite solder large eyes beetle

I used the information from the "Insects" drawing.
When the output is run through links -dump filename it outputs:

+------------------------------------------------------------------ +------+ | insects + | |------------------------------------------------------------------ +------| | large wings | small or no wings + | |-------------+---------------------------------------------------- +------| | butterfly | very long rear legs | shorter rear legs + | |-------------+--------------------------+------------------------- +------| | | antenna | antenna rear | horned | not horned h +ead | | | front | | head | + | |-------------+-----------+--------------+---------+--------------- +------| | | mosquito | grasshopper | rhino | small | l +arge | | | | | beetle | eyes | e +yes | |-------------+-----------+--------------+---------+-----------+--- +------| | | | | | termite | be +etle | | | | | | solder | + | +------------------------------------------------------------------ +------+

Of course, it can also be viewed in a browser.

insects
large wings small or no wings
butterfly very long rear legs shorter rear legs
antenna front antenna rear horned head not horned head
mosquito grasshopper rhino beetle small eyes large eyes
termite solder beetle


Wow, that worked :)

UPDATE: fixed typo in comment


In reply to Re: Drawing A Dichotomous Key by tybalt89
in thread Drawing A Dichotomous Key by varanasi

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.