List::StackBy - Group runs of similar elements
use List::StackBy; my @uniq = map { $_->[0] } stack_by { uc } qw/A B b A b B A/; # A B A b A my @by_col1 = map { /^\s*(\d+)/ ? $1 : undef } ( "123,foo", "123,bar", "456,baz", ); # ["123,foo", "123,bar"], # ["456,baz"]
This module provides the function stack_by.
stack_by
Applies the code block to each item in the list and returns a list of arrays containing runs of elements for which the code block returned the same value. Items for which the code block returns an undefined value are isolated from the rest.
stack_by by default.
Copyright (c) 2018 Bjoern Hoehrmann <bjoern@hoehrmann.de>. This module is licensed under the same terms as Perl itself.
To install List::StackBy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::StackBy
CPAN shell
perl -MCPAN -e shell install List::StackBy
For more information on module installation, please visit the detailed CPAN module installation guide.