Help for this page

Select Code to Download


  1. or download this
    my $data = [
       [ 'parent1', 'child1a', 'child2a', undef,    ],
       [ 'parent1', 'child1b', 'child2b', 'child3b',],
       [ 'parent1', 'child1c', undef, undef,],
    ];
    
  2. or download this
    my @results;
    foreach my $row (@$data) {
       push @results, treeify(@$row);
    ...
       return {} unless $node;
       return {$node => treeify(@list)};
    }
    
  3. or download this
    $VAR1 = {
              'parent1' => {
                             'child1a' => {
    ...
                             'child1c' => {}
                           }
            };