The oracle database has a
CONNECT statement
which allows for easy traversing of hierarchically coded
info:
SELECT LEVEL, SUB, SUPER
FROM PARTS
CONNECT WITH PRIOR SUPER = SUB
LEVEL is a builtin Oracle variable which tells
you current depth of traversal. SUB and SUPER are table
columns which show which parts are subordinate to others.
And of course, you can use LPAD():
SELECT, LEVEL, LPAD(' ', LEVEL, SUB), SUPER;
to "tab over" each degree of recursion. Or write your
own function to create display as needed.
Perl is nice, but server side database preprocessing
can be faster and more definitional.