You want grep. Here is an example:
@ary = qw(just another perl foo hacker); @no_foo = grep{ $_ ne 'foo' }@ary; print "@no_foo"
The grep function examines the whole of the @ary array, aliasing each value in turn to $_ within the { }. If the value within the { } is true then that element is added to the list that grep returns. In this case grep returns a list of all the values that are not equal to 'foo'. Thus we have used it to remove one value from the array. Although I have assigned the result to the @no_foo array I could have just as easily assigned it back to @ary. This is just a simple example of what grep can do - it is a really handy function and well worth getting familiar with. Because we alias to $_ you can include a match type regex like /foo|bar/ which will return all the elemnts of the array that match either foo or bar.
cheers
tachyon
In reply to Re: finding and deleting item from an array
by tachyon
in thread finding and deleting item from an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |