# Emulate grep with map @a = map { elementShouldBeIncluded($_) ? $_ : () } @a; # Double up the list @a = map { ($_, $_) } @a;