In a later mail the OP has mentioned that her list may be of the form
my @ops_list = ("a", "b=7", "c=8");
The first element does not have a "=" in it. I am assuming that the key that
she uses for search here is "a".
Your code snippet will return an undef when called with some_func (@ops_list,
"a").

The return statement if the key exists should be
return $i if ((index($_, "$key=") == 0) || ($_ eq $key))


Bob Showalter wrote:

>
>
> A simple sequential search:
>
>    sub some_func
>    {
>        my $key = pop;
>        my $i = '0e0';
>        for (@_) {
>            return $i if index($_, "$key=") == 0;
>            $i++;
>        }
>        return undef;
>    }
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to