in reply to Map function that does not return undefined values
and will only get back the defined elements (kind of like you could do with grep, but more powerful)map { defined $_ ? $_ : () } @array;
all you have to do is add more interesting code to the map. Hope that is what you wanted...
Update BTW - you can also use that to add extra items to the array. If you return a list of multiple items from the code in map they will all be added to the output
print join(',',map { ($_,$_*2,$_*3) } (1,5)); #prints: 1,2,3,5,10,15
- Ant
- Some of my
best work - (1 2 3)
|
|---|