@array = grep !defined || $_ ne 'hello', @array;
The grep built-in function takes a list (in this case supplied by @array) and returns only those elements of the list for which the BLOCK or EXPRESSION of the function evaluates true. In this case, the expression is
!defined || $_ ne 'hello'
and only elements of the input list that are either not defined or not string-equal to 'hello' are output. A better name for the grep function might be 'filter'.
In reply to Re^5: How can I delete an element in a foreach cycle?
by AnomalousMonk
in thread How can I delete an element in a foreach cycle?
by saintex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |