平铺多维数组最简单的方法是什么?
解决方法
使用
List::Flatten
似乎最简单:
use List::Flatten; my @foo = (1,2,[3,4,5],6,[7,8],9); # @foo contains 6 elements,2 of them are array references my @bar = flat @foo; # @bar contains 9 elements,same as (1 .. 9)
使用List::Flatten::Recursive
递归地执行.