#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @temp = do { no warnings 'qw'; qw( a b c #%# #%#a #%#b ) }; @temp = grep /#%#/ && ! /#%#$/, @temp; say "@temp.";