Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Multi @array searches

by akm2 (Scribe)
on Mar 24, 2001 at 03:12 UTC ( [id://66784]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://66784]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found