[ic] Recursive Perl Function?

Mike Heins mikeh@minivend.com
Thu, 29 Mar 2001 11:11:10 -0500

Quoting Craig Beasland (craig@hotmix.com.au):
> Hi there,
> We would like to add a simple Bulletin Board system to one of our systems.
> The simple solution is to add a function which display a line from the
> BBtable, calls itself to see if there are any "children" which in turn calls
> itself and so on.

You might check out the [tree ...] tag in 4.7.x. It allows you to
specify a master item (thread) and then walk down the tree.

You would want a SQL database for it, though, as I think the
overhead for GDBM would be high. And indexing is a must.

id	parent	code	message
1	99	a
2	a	b
3	a	c
4	a	d
5	a	x
6	x	y
7	x	z
8	99	m
9	99	n
10	99	o
11	o	e
12	o	f
13	o	g

The above sample data would produce:

    a           mv_level=0, mv_increment=1, mv_children=4
        b       mv_level=1, mv_increment=1, mv_children=0
        c       mv_level=1, mv_increment=2, mv_children=0
        d       mv_level=1, mv_increment=3, mv_children=0
        x       mv_level=1, mv_increment=4, mv_children=2
            y   mv_level=2, mv_increment=1, mv_children=0
            z   mv_level=2, mv_increment=2, mv_children=0
    m           mv_level=0, mv_increment=1, mv_children=0
    n           mv_level=0, mv_increment=2, mv_children=0
    o           mv_level=0, mv_increment=3, mv_children=3
        e       mv_level=1, mv_increment=1, mv_children=0
        f       mv_level=1, mv_increment=2, mv_children=0
        g       mv_level=1, mv_increment=3, mv_children=0

from the tag call:

    [tree   start=99

Red Hat, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mheins@redhat.com>

Unix version of an Outlook-style virus:
It works on the honor system. Please forward this message to everyone
you know, and delete a bunch of your files at random.