List::Slice - Slice-like operations on lists
version 0.003
use List::Slice qw( head tail );
This module provides functions for slicing lists. This is helpful when you want to do a chain of manipulations on a list (map, grep, sort) and then slice, without the cumbersome (...)[x] syntax.
(...)[x]
my @values = head $size, @list;
Returns the first $size elements from @list. If $size is negative, returns all but the last $size elements from @list.
$size
@list
@result = head 2, qw( foo bar baz ); # foo, bar @result = head -2, qw( foo bar baz ); # foo
my @values = tail $size, @list;
Returns the last $size elements from @list. If $size is negative, returns all but the first $size elements from @list.
@result = tail 2, qw( foo bar baz ); # bar, baz @result = tail -2, qw( foo bar baz ); # baz
List::Util, List::MoreUtils, List::UtilsBy
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2015 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install List::Slice, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Slice
CPAN shell
perl -MCPAN -e shell install List::Slice
For more information on module installation, please visit the detailed CPAN module installation guide.