in reply to Basic list manipulation, and a bit of map() confusion...
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Basic list manipulation, and a bit of map() confusion...
by jwkrahn (Abbot) on Feb 24, 2008 at 19:17 UTC | |
by Corion (Patriarch) on Feb 24, 2008 at 19:25 UTC | |
by jwkrahn (Abbot) on Feb 24, 2008 at 22:47 UTC | |
by kyle (Abbot) on Feb 24, 2008 at 23:00 UTC |