sub alphabeta { my ($self, $test) = @_; ... foreach ... if (!... || ... && ...) { push @foo, [ @bar ] if !$test || $self->{baz} eq $gamma; } } push @foo, [ @bar ] if !$test || $self->{baz} eq $gamma; return \@foo; }