in reply to Idiomatic Array Index Search?
There's no reason to get more idiomatic, because it will cloud the meaning of your code. The most simple things should be coded simply.# prototype here for "look and feel good"ness # if you remove it, be sure to pass array by # reference (this is done for speed reasons) # $index = get_index @array, $element; sub get_index (\@$) { my ($a, $e) = @_; my $i = 0; for (@$a) { return $i if $e eq $_; $i++; } return -1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple things should be coded simply (Re: Idiomatic Array Index Search?)
by merlyn (Sage) on May 28, 2001 at 20:33 UTC | |
|
Re: Simple things should be coded simply (Re: Idiomatic Array Index Search?)
by mattr (Curate) on May 28, 2001 at 18:57 UTC | |
by japhy (Canon) on May 28, 2001 at 19:21 UTC |