my @filter_string_array = ('192\.168\.200\.|10\.10\.200',',SEVERE,'); ... my @local_filter_string_array = @filter_string_array; my $first_filter_string = shift @local_filter_string_array; my @output = grep {/$first_filter_string/} <$FILE>; foreach my $filter_string (@local_filter_string_array){ @output = grep {/$filter_string/} @output; }