in reply to Deleting an array entry
@filtered = grep { $_ ne $current_log } @original;
If instead, you have an array index instead of a condition, use splice(). The next will delete the third item:
This modifies the original array, instead of making a filtered copy. Well, you can always use an array slice:splice @array, 2, 1;
The grep makes a complete list of all array items, from 0 to $#original, but without the 2.@filtered = @original[grep { $_ != 2 } 0 .. $#original];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting an array entry
by Jaspersan (Beadle) on Nov 28, 2002 at 17:56 UTC |