sub func { my($hr_h, $ar_l, $this) = @_; # instead of all the shift, shift, shift # seems quite clear my @these; # I'll try to wantarray too. foreach my $i (keys(%$hr_h)) { if($i == $$ar_l[$i] && $hr_h->{$i} == $this) { .... push(@these, $ar_l->[$i]); } } wantarray? @these: \@these; } # not the best of examples but shows 2 ways to talk with # an array pointer and uses (for good) of wantarray as the # return value.