in reply to How do I find the position of an element in an array?
Of course, this method and the repeated-greps method both have their own idiosyncratic costs, so which one is more effective/efficient for you really depends on your situations.my @array = ( ... ); my %array_element_index; @array_element_index{ @array } = (0 .. $#array); my $i = $array_element_index{ $value_of_interest };
|
---|