my @array = (); sub processA { push(@array,$some_data); common_stuff(); # clear the array? } sub processB { for(1 .. 1000) { push(@array,$some_data); } common_stuff(); # clear the array? } sub common_stuff { foreach(@array) { #do stuff ... } }