Personally I would use a grep before or after the map, but when you want to return a varying number of elements from map you can use the ternary operator:
my @b = map { s/x//; # this could be written more efficient as tr[x][]d; $_ ? $_ : () } @a;
In reply to Re: Basic list manipulation, and a bit of map() confusion...
by Corion
in thread Basic list manipulation, and a bit of map() confusion...
by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |