print <
) { # get rid of annoying tabs and \n chomp; s/^(\t*)//; # how many tabs? $tabs=length($1); # give it an id ++$idcount; # get the parent $parent=$parent[$tabs]+0; # set the parent $parent[$tabs+1]= $idcount; # print printf "| %2d | %-18s | %6d |\n", $idcount, $_, $parent; } print <