for my $textfile (@textfiles) { if (grep) { push @results, $textfile; } } do_something_with(@results);