in reply to What's the idiom for finding and removing the found @ARRAY element?

Hrm. Is there anything wrong with: @array = grep { not /$pattern/ } @array;

Update: I guess I didn't register the parts of your post where you sort of talk about that. :) But I still think it's the clearest, unless you're wanting to remove just one element, even if it isn't the most efficient in many situtations. I tend to only bother remembering the clear idioms, as you can always look up the efficient ones if you really need to.

bbfu
Black flowers blossum
Fearless on my breath

  • Comment on Re: What's the idiom for finding and removing the found @ARRAY element?
  • Download Code

Replies are listed 'Best First'.
Re: Re: What's the idiom for finding and removing the found @ARRAY element?
by chromatic (Archbishop) on Nov 06, 2002 at 07:06 UTC

    I think he only needs it to work on a reference:

    $arrayref = [ grep { not /$pattern/ } @$arrayref ];