http://www.perlmonks.org?node_id=954933


in reply to Does Scope of Referenced Array Matter?

Try this:
sub a_sub { my @array = qw /a b c d e f g/; $ref = \@array; } a_sub(); print "$ref - @$ref - @array";
Output:
ARRAY(0x9dbb04) - a b c d e f g - 
The @array does not evaporate, although it can no longer be reached outside of the scope of its enclosing sub by using its lexical name. Actually the @array in the print statement has nothing to do with the @array in the sub.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics