in reply to Referncing a local array outside

You really ought to be using the my declaration there to create a lexically scoped variable, as opposed to local which creates a new, dynamically scoped instance of the given package variable (or hash element or array item). So in your case you're creating a dynamically scoped new instance of the package variable @ARRAY for each loop iteration, whereas you ideally want a lexically scoped variable bound to the current scope (which would the body of the loop in this case). For more information on variables and scoping within perl see. Lexical scoping like a fox.
HTH

_________
broquaint