This traverses the whole tree, and every time there's a match, pushes the current node to this array.This sounds like a case for having the array as a property of the Tree object as it is a property which relates directly to the object. At the very least you could use a lexical over package variable as it isn't needed in your case.
But I have a feeling I'm breaking some fundamental OO rules, or maybe this is an example of a ghastly global variable?I think if you're just writing a small program then it's alright to have somewhat messy OO as long as you're sure it's just a throwaway script. Much like using strict it's a good habit to get into applying proper OO structure to your programs consistently so that your skill remains honed and you're less likely to slip up in future.
_________
broquaint
In reply to Re: Global variables
by broquaint
in thread Improper use of global variable? (was: Global variables)
by Basilides
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |