for my $var (@vars) { if (my $found = something_with_any($var, \@othervar)) { print join("\t", ($var, $found))."\n"; } }