use vars qw($big_array); sub get_big_array { if (!$big_array) { $big_array = [ ... construct big array... ]; } return $big_array; } sub clear_big_array { undef $big_array; } sub processA { common_stuff($_); # special stuff } sub processB { loop (1..1000) { common_stuff($_); # special stuff } } sub common_stuff { my $ba = get_big_array(); ... }