my @b = map { s/x//; # this could be written more efficient as tr[x][]d; $_ ? $_ : () } @a;