in reply to Re: Basic list manipulation, and a bit of map() confusion...
in thread Basic list manipulation, and a bit of map() confusion...
s/x//; # this could be written more efficient as tr[x][]d;
The difference being that s/x// removes one 'x' character while tr[x][]d removes all 'x' characters. To be fair, the OP's code used s/x//g instead :-)
And you don't need two statements to accomplish that:
my @b = map s/x//g ? $_ : (), @a; # Or: my @b = map tr/x//d ? $_ : (), @a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Basic list manipulation, and a bit of map() confusion...
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 |