cat1 cat1,sub1 cat1,sub1,sub-sub1 cat1,sub2 cat2 cat3 cat3,sub1 #### ------------------------------------ | id | name | parent | ------------------------------------ | 1 | cat1 | 0 | | 2 | cat1,sub1 | 1 | | 3 | cat1,sub1,sub-sub1 | 2 | | 4 | cat1,sub2 | 1 | | 5 | cat2 | 0 | | 6 | cat3 | 0 | | 7 | cat3,sub1 | 6 | ------------------------------------ #### my @x = ('cat1', ['cat1,sub1', ['cat1,sub1,sub-sub1'], 'cat1,sub2'], 'cat2', 'cat3', ['cat3,sub1'], ); #### $x[0] is SCALAR 1/0 (id/parent) $x[1] is ARRAY $x[1][0] is SCALAR 2/1 $x[1][1] is ARRAY $x[1][1][0] is SCALAR 3/2 $x[1][1][1] isn't defined $x[1][2] is SCALAR 4/1 $x[1][3] isn't defined $x[2] is SCALAR 5/0 $x[3] is SCALAR 6/0 $x[4] is ARRAY $x[4][0] is SCALAR 7/6 $x[4][1] isn't defined $x[5] isn't defined