in reply to multiple consumer of an array

This may not help you as it requires modification of your subroutines and assumes they will always be used together. It makes use of the fact that calling a subroutine from inside another in the form &sub_name without any parentheses or arguments passes the arguments (@_) of the calling routine to the called one. Obviously, modification of arguments before calling subsequent routines will break this model and careful consideration of order is required, e.g. we can't calculate the average before we've got the sum.

$ perl -Mstrict -Mwarnings -E ' my $rsSum = \ do { my $dummy }; my $rsAvg = \ do { my $dummy }; sub sum (@) { ${ $rsSum } += $_ for @_; &avg; } sub avg (@) { ${ $rsAvg } = ${ $rsSum } / scalar @_; } sum( 3, 4, 5, 6, 7 ); say qq{Sum - ${ $rsSum }\nAvg - ${ $rsAvg }};' Sum - 25 Avg - 5 $

I hope this is of interest.

Update: Regarding order, calling &sum from sub avg before calculating the average also works.

$ perl -Mstrict -Mwarnings -E ' my $rsSum = \ do { my $dummy }; my $rsAvg = \ do { my $dummy }; sub avg (@) { ∑ ${ $rsAvg } = ${ $rsSum } / scalar @_; } sub sum (@) { ${ $rsSum } += $_ for @_; } avg( 3, 4, 5, 6, 7 ); say qq{Sum - ${ $rsSum }\nAvg - ${ $rsAvg }};' Sum - 25 Avg - 5 $

Cheers,

JohnGG