
List::Extract - grep and splice combined

use List::Extract 'extract';
my @keywords = qw/
foo
!bar
baz
/;
my @exclude = extract { s/^!// } @keywords;
print "Keywords: @keywords\n";
print "Exclude: @exclude\n";
__END__
Keywords: foo baz
Exclude: bar

List::Extract exports a grep-like routine called extract that both returns and extracts the elements that tests true. It's grep and splice combined.

Nothing is exported by default. The :ALL tag exports everything that can be exported.
Removes the elements from array for which BLOCK returns true. In list context the elements are returned in original order. In scalar context the number of removed elements is returned.
In BLOCK the elements in ARRAY will be accessible through $_. Modifications to $_ will be preserved in the returned list, but discarded for elements left in the array.

Johan Lodin <lodin@cpan.org>

Copyright 2007-2008 Johan Lodin. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
