We often need to parse "newick" format phylogentic trees to figure out some information. Writing a parser is good for the soul, because the best way to do it is through recursion.
After the readmore, I provide some perl code for parsing newick phylogenetic trees into a lightweight data structure. Each node consists of an array of three things [left child, right child, and distance]. If the node is a leaf then the node consists of ["node", the node name, and the distance]. It allows for very easy analysis of the tree, and simple ways to get data back. I also provide some example code for printing out the root-to-tip distance of every leaf in the tree.



Rob