... sub check { my $seen = 0; for my $el (@{shift(@_)}) { if ($el eq '3'){ # we only need the first occurrence $seen = 1; last; } } return $seen == 1? 'Found': 'Not Found'; # NOTE } ...