grep iterates through @numbers, sets $_ to the current element and if the block returns true, the element will be in the output list. so just call foo inside the grep block with $_ and it should work.F:\>perl use strict; use warnings; my @numbers = 1 .. 10; @numbers = grep { $_ > 4 } @numbers; print "@numbers"; ^D 5 6 7 8 9 10 F:\>
In reply to Re: Removing Items from an Array
by kabel
in thread Removing Items from an Array
by ibanix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |