neniro has asked for the wisdom of the Perl Monks concerning the following question:
In my snippet above the block is a fixed part of the grep statement. Is it possible to pass a block to the subroutine and use it within the grep statement?sub selected { my $arr_ref = shift; die "selected: need an arrayref" unless (ref $arr_ref eq "ARRAY"); return grep {($_ > 35)} @$arr_ref; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to pass blocks to subroutines
by exussum0 (Vicar) on Jun 12, 2004 at 16:03 UTC | |
by neniro (Priest) on Jun 12, 2004 at 16:25 UTC | |
|
Re: How to pass blocks to subroutines
by neniro (Priest) on Jun 12, 2004 at 17:07 UTC | |
by Sidhekin (Priest) on Jun 12, 2004 at 17:13 UTC | |
by neniro (Priest) on Jun 12, 2004 at 17:26 UTC | |
by exussum0 (Vicar) on Jun 12, 2004 at 23:57 UTC |