my @a = ( qw (onexxx txwxo txhrexe xfourx xxx five) ); my @b = map { $_ =~ s/x//g; $_ ? $_ : (); } @a; print Dumper(\@b); __END__ $VAR1 = [ 'one', 'two', 'three', 'four', 'five' ];