The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Acme::CPANModules::RemovingElementsFromArray - List of modules to help remove elements from array


This document describes version 0.003 of Acme::CPANModules::RemovingElementsFromArray (from Perl distribution Acme-CPANModules-RemovingElementsFromArray), released on 2023-09-30.


Perl provides several ways to remove elements from an array. shift removes one element from the beginning, pop removes one element from the end, and splice removes a slice of array (and insert another list in its place). There's also grep, which lets you filter a list with a user-supplied code. While this does not directly modify an array, you can simply assign the new filtered values to the array. And I might just as well mention array slice (@ary[1,3,4] or @ary[1..4]) which allows you to pick the range of elements you want by their indices.

In addition to the above, there are also other modules which provide some convenience.

Removing duplicate items

List::Util provides uniq (as well as uniqnum, uniqint, uniqstr) to remove duplicate items from a list. There's also List::Util::Uniq providing dupe, dupenum, dupeint, and dupestr, which return the duplicates instead.

Removing overlapped items

Array::OverlapFinder lets you find overlapping items from a series of arrays and optionally remove them.

Variations of grep

Some modules offer variations of grep. For example, Array::KeepGrepped keeps the elements that are filtered out instead those that match the grep expression. List::Util::sglice offers sglice, which removes elements that matches user-supplied code, except that sglice (like splice) allows you to specify a limit to the number of elements to remove.


List::Util::mapsplice offers mapsplice, which removes a slice of array but lets you replace each element with new elements using Perl code.



Author: PEVANS











What is an Acme::CPANModules::* module?

An Acme::CPANModules::* module, like this module, contains just a list of module names that share a common characteristics. It is a way to categorize modules and document CPAN. See Acme::CPANModules for more details.

What are ways to use this Acme::CPANModules module?

Aside from reading this Acme::CPANModules module's POD documentation, you can install all the listed modules (entries) using cpanm-cpanmodules script (from App::cpanm::cpanmodules distribution):

 % cpanm-cpanmodules -n RemovingElementsFromArray

Alternatively you can use the cpanmodules CLI (from App::cpanmodules distribution):

    % cpanmodules ls-entries RemovingElementsFromArray | cpanm -n

or Acme::CM::Get:

    % perl -MAcme::CM::Get=RemovingElementsFromArray -E'say $_->{module} for @{ $LIST->{entries} }' | cpanm -n

or directly:

    % perl -MAcme::CPANModules::RemovingElementsFromArray -E'say $_->{module} for @{ $Acme::CPANModules::RemovingElementsFromArray::LIST->{entries} }' | cpanm -n

This Acme::CPANModules module also helps lcpan produce a more meaningful result for lcpan related-mods command when it comes to finding related modules for the modules listed in this Acme::CPANModules module. See App::lcpan::Cmd::related_mods for more details on how "related modules" are found.


Please visit the project's homepage at


Source repository is at


Somewhat related lists pertaining to list/array: Acme::CPANModules::GroupingElementsOfArray. Acme::CPANModules::PickingRandomItemsFromList, Acme::CPANModules::Import::RSAVAGE::ArrayAndSetOperations, Acme::CPANModules::Import::MJGARDNER::ListProcessing.

Acme::CPANModules - about the Acme::CPANModules namespace

cpanmodules - CLI tool to let you browse/view the lists


perlancar <>


To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.


This software is copyright (c) 2023 by perlancar <>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.