> Date: Wed, 4 Dec 2002 19:21:27 -0800
> From: Michael G Schwern <[EMAIL PROTECTED]>
>
> On Wed, Dec 04, 2002 at 08:08:48PM -0700, Luke Palmer wrote:
> > About your idea, though, I'm rather indifferent. However, a friend of
> > mine once asked me if Perl had "search" or "find" operation, returning
> > the I<index> of matching elements. Now am I just being braindead, or
> > is Perl actually missing this operation? Do you really have to:
> >
> > my $index;
> > for @a {
> > last if la_dee_daa;
> > $index++;
> > }
> >
> > That can't be right....
>
> You can do it with a map without much trouble:
>
> my @indexes = map { /condition/ ? $i++ : () } @stuff;
Braindead. Right. :)
> Its so rare that you work by array index in Perl. Usually things flow
> together element by element. Sort of like how you rarely handle strings
> character by character which can severely confuse C programmers.
Agreed completely. I was surprised when he asked me that I had come
this far without ever needing it. Kinda like the C for loop; I never
use that anymore.
> What was your friend trying to do?
Don't remember. Thanks for pointing the map thing out, though.
Luke