in reply to RFC: List::Extract
use strict; use warnings; my @array = ( 3, 13, 73, 4, 29, 38 ); print qq{Before:\n}, qq{ @array\n}; my $rcExtract = sub { my $toTest = shift; return $toTest > 31 ? 1 : 0; }; my @extracted = reverse map { splice @array, $_, 1 } grep { $rcExtract->( $array[ $_ ] ) } reverse 0 .. $#array; print qq{After:\n}, qq{ @array\n}, qq{ @extracted\n};
The output.
Before: 3 13 73 4 29 38 After: 3 13 4 29 73 38
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RFC: List::Extract
by lodin (Hermit) on Nov 24, 2007 at 23:09 UTC | |
by johngg (Canon) on Nov 24, 2007 at 23:43 UTC | |
|
Re^2: RFC: List::Extract
by kyle (Abbot) on Nov 25, 2007 at 03:23 UTC | |
by johngg (Canon) on Nov 27, 2007 at 13:48 UTC |