[Bioperl-l] help, please. newick.pm error

Aaron J. Mackey amackey at pcbi.upenn.edu
Thu Jun 10 09:26:09 EDT 2004

It's rather subtle, but $neighbor_factory->run() returns either an 
array or array reference, depending on the context; you're calling it 
in scalar context, so it's returning an arrayref (the first element of 
which is the tree you want).  In sum, change this line:

my $tree = $neighbor_factory->run($matrix);

To this:

my ($tree) = $neighbor_factory->run($matrix);


P.S. Developer's note: I think this is a misuse of wantarray; typically 
the Perl idioms for context-sensitive returns is that scalar context 
implies I only want the "size of" or "truthness/success" of the result, 
not "package my results some other way than an array".  Since neither 
"size of" nor "truthness" of a factory run method seems appropriate, 
I'd vote for culling this and similar uses.

Aaron J. Mackey, Ph.D.
Dept. of Biology, Goddard 212
University of Pennsylvania       email:  amackey at pcbi.upenn.edu
415 S. University Avenue         office: 215-898-1205
Philadelphia, PA  19104-6017     fax:    215-746-6697

More information about the Bioperl-l mailing list