$VAR1 = [ '830974','722065','722046','716963' ];
如何计算值“722065”的数组索引?
解决方法@H_301_8@
List::MoreUtils的firstidx功能可以帮助您:
use strict;
use warnings;
use List::MoreUtils qw(firstidx);
my @nums = ( '830974','716963' );
printf "item with index %i in list is 722065\n",firstidx { $_ eq '722065' } @nums;
__END__
item with index 1 in list is 722065
use strict; use warnings; use List::MoreUtils qw(firstidx); my @nums = ( '830974','716963' ); printf "item with index %i in list is 722065\n",firstidx { $_ eq '722065' } @nums; __END__
item with index 1 in list is 722065