in reply to Re: Multi @array searches
in thread Multi @array searches

my @matches = grep { $names[$_] =~ /$pattern/ || $desc[$_] =~/$pattern/ } 0 .. $#names;

Shouldnt it read:

my @matches = grep { $names[$_] =~ /$pattern/ || $desc[$_] =~/$pattern/ } 0 .. $#desc;

If not, why not?

Replies are listed 'Best First'.
Re: Re: Re: Multi @array searches
by arturo (Vicar) on Mar 24, 2001 at 03:25 UTC

    Recall that 0 .. $#array; gives you a list of all the values between 0 and the maximum index of @array, or, in other words, the list of the indexes of @array.

    That bit of code assumes (and I made this assumption explicit) that the members of @names map 1:1 onto members of @desc; and if that is true, then

    0.. $#names
    and
    0 .. $#desc

    yield up the same list, so either is acceptable.

    HTH!

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor