Should re-rewrite so you can pull all arguments on one line instead of many. i.e
my ($tree) = @_;

Info @ http://modernperlbooks.com/books/modern_perl_2014/05-perl-functions.html