#!/opt/exp/bin/perl5.8 use strict; use warnings; use Data::Dumper; my @a = ( qw (onexxx txwxo txhrexe xfourx xxx five) ); my @b = map { $_ =~ s/x//g; $_ if ($_); } @a; print Dumper(\@b);