Being new to Perl, one of the things that you want to avoid is getting mixed up with your scalars and arrays, which is easy to do when you use similar names for your scalars and arrays (i.e. $species and @species). Whilst, it is true that this word uses the same form for its singular and plural forms, a more apt name may be $sp for you scalar variable (i.e. singular abbreviation). It is not considered good form to name variables as you have done here.
You may also want to read up on variable scoping rules in Perl to understand why my @tree is not accessible outside the for loop.