in reply to Deleting specific element in array in FOREACH loop

Grep is god's gift to this situation. Check out grep. Basically, you can write a subroutine that takes the array element as an input and returns true or false, true if it should be included.

Then you write a version of  @newarray=grep {&subroutine($_)} @oldarray. The new array will only contain the elements that the subroutine returned true for.

Hays

Replies are listed 'Best First'.
Re^2: Deleting specific element in array in FOREACH loop
by awohld (Hermit) on Sep 15, 2006 at 20:36 UTC
    Ahhh, I never thought about using a subroutine in the grep expresssion! That's really good info.