Array::Extract - extract element from an array
use Array::Extract qw(extract); # remove those members from @members who are # blackballed and store them in @banned my @banned = extract { $_->blackballed } @members;
Function to extract elements from an array that match a block. See Array::Extract::Example for a more comprehensive example of how this can be useful
The function is exported on demand
Removes elements from the ARRAY that match the block and returns them.
# leave just the even numbers in @numbers my @numbers = (1..100); my @odds = extract { $_ % 2 } @numbers;
Care is taken to do the least number of splice operations as possible (which can be important when the array is a tied object with a class such as Tie::File)
Written by Mark Fowler <mark@twoshortplanks.com>
Copyright Mark Fowler 2011. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This module (deliberately) does not alias $_ to the actual array element within the block
$_
Bugs should be reported via this distribution's CPAN RT queue. This can be found at https://rt.cpan.org/Dist/Display.html?Array-Extract
You can also address issues by forking this distribution on github and sending pull requests. It can be found at http://github.com/2shortplanks/Array-Extract
Array::Extract::Example List::Util, List::MoreUtils, Tie::File
To install Array::Extract, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Array::Extract
CPAN shell
perl -MCPAN -e shell install Array::Extract
For more information on module installation, please visit the detailed CPAN module installation guide.