在Perl中,如何在数组中找到给定值的索引?
发布时间:2020-12-15 21:12:32 所属栏目:大数据 来源:网络整理
导读:$VAR1 = [ '830974','722065','722046','716963' ]; 如何计算值“722065”的数组索引? 解决方法 List::MoreUtils的firstidx功能可以帮助您: use strict;use warnings;use List::MoreUtils qw(firstidx);my @nums = ( '830974','716963' );printf "item wit
$VAR1 = [ '830974','722065','722046','716963' ]; 如何计算值“722065”的数组索引? 解决方法
List::MoreUtils的firstidx功能可以帮助您:
use strict; use warnings; use List::MoreUtils qw(firstidx); my @nums = ( '830974','716963' ); printf "item with index %i in list is 722065n",firstidx { $_ eq '722065' } @nums; __END__ item with index 1 in list is 722065 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |