in reply to Binary vs. linear search
++ for the good work, the code is well written and structured, not much else to add.
FYI though, the last item of @array is at the index $#array. This means that the two following lines are equivalent
And the for loop could be rewritten asmy $high = @$array - 1; my $high = $#$array;
for my $try ( 0..$#$array ) { say "--> trying at index $try"; if ( $array->[$try] eq $find ) { return $try; } }
|
|---|