my $find_item = "c"; my @array_I_just_created_here = (a .. z); my $pos = bin_search(\@array_I_just_created_here, $find_item, 0, $#array_I_just_created_here); print "yes, c is a letter that would exist within that array you just created there.$/" if ($a[$pos] eq $find_item); sub bin_search { my ($array, $val, $min, $max) = @_; my $pos = int($min + $max / 2); my $check = $val cmp $array->[$pos]; if ($check == -1) { $pos--; return $pos if ($pos <= $min); return bin_search($array, $val, $min, $pos); } elsif ($check == 0) { return $pos; } else { $pos++; return $pos if ($pos >= $max); return bin_search($array, $val, $pos, $max); } }