$VAR1 = [ '830974', '722065', '722046', '716963' ];
How can I calculate the array index for the value "722065"?
The firstidx function from List::MoreUtils can help:
firstidx
use strict; use warnings; use List::MoreUtils qw(firstidx); my @nums = ( '830974', '722065', '722046', '716963' ); printf "item with index %i in list is 722065 ", firstidx { $_ eq '722065' } @nums; __END__
item with index 1 in list is 722065
1.4m articles
1.4m replys
5 comments
57.0k users