my (@isec , @b ) = (); (@b, @isec) = ArrayFunctions(\@ArrayA, \@ArrayB, \@b, \@isec); sub ArrayFunctions { my $a_ref = shift; # reference to input array A my @a = @$a_ref; # input array A my $b_ref = shift; # reference to input array B my @b = @$b_ref; # input array B my $b = shift; # input array Bonly my $isec = shift; # input array isec_plus_bonly my @Aseen{@a} = (); # lookup table my @Bseen{@b} = (); # lookup table #.......... Other Code ..... }