for my $a_val (@a) { (my $s = $a_val) =~ s/x//g; push @b, $s if $s; }