in reply to Parsing newick trees
Cool - We get a chance to use the "seldom used" ForceContent=>1 and ContentKey=>'keyname' options of XMLin. :-)
use XML::Simple; sub parse_newick { local $_ = shift; s<[(]>[<LEFT>]g; s<[,]>[</LEFT><RIGHT>]g; s<[)]>[</RIGHT>]g; XMLin "<opt>$_</opt>", ForceContent => 1, ContentKey => 'VALUE'; } use Data::Dumper; print Dumper parse_newick( '(A,(B,C))' );
|
|---|