my @tmp; foreach (qw(a b c)) { push @tmp, $_ if qr(a); } print @tmp;