in reply to Does Scope of Referenced Array Matter?

"my" allocates a new variable, so what you're doing is completely safe.

(Optimisations normally cause the variable to be reused, but they are specifically disabled when a reference escapes the scope like here.)

Well, the needless use of a global variable probably isn't that safe. Return the reference instead.

use strict; # Always! use warnings; # Always! B(A()); sub A { my @array = qw(value_1 value_2); return \@array; } sub B { my ($array_ref) = @_; foreach my $i ( @{$array_ref} ) { print "Array Value: $i \n"; } }