且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Perl中通过索引从数组中排除元素的***方法是什么?

更新时间:2023-11-27 09:02:52

您不需要任何东西除了数组切片之外,因此我避免为此创建一个子项。

You don't need anything beyond an array slice, so I'd avoid creating a sub just for this.

my @wanted = @array[@indices];

如果使用数组引用,则适用相同的配方:

If you're working with array references, the same recipe applies:

my @wanted = @{$array}[@$indices];