|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Flatten sparse AoAby FloydATC (Friar) |
| on Jan 22, 2012 at 17:25 UTC ( #949265=perlquestion: print w/ replies, xml ) | Need Help?? |
|
FloydATC has asked for the
wisdom of the Perl Monks concerning the following question:
I have a "sparse" AoA ref where each element may be either defined or undefined. I can flatten the entire structure using
@flat = map { @$_ } @{$aoa}; but is there a more efficient way to eliminate all the undefs right there inside the map() so I won't have to loop through the @flat array or invoke grep() to do it for me? @flat = grep { defined } map { @$_ } @{$aoa}; I don't really know if this is even an issue, I'm just curious since practical uses of map() have always been a bit of a mystery for me.
--
Time flies when you don't know what you're doing
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||