sub getDeep { my @data = (@_); my ($bighash,$hash); #First read foreach my $idx (0.. $#data) { my ($spaces, $content) = ($data[$idx] =~ m/^(\s*)(.*)/); my $depth = length $spaces; $bighash->{node}{$idx}{depth} = $depth; } # Variables for the first read my $ldepth = 0; my $lcontext; my $lid; # Second read foreach my $id (0 .. $#data) { $data[$id] =~ s/^\s*//; next if ($data[$id] =~ /^!/); my $depth = $bighash->{node}{$id}{depth}; if ($depth eq 0) { push (@{$hash->{global}} , $data[$id]); $lcontext = $data[$id]; $lid = $id; } if (($depth gt 0) && ($id - $lid eq 1)) { push (@{$hash->{$lcontext}}, (" " x $depth. $data[$id])); $lid = $id; } } return $hash; }