NAME List::Util::Uniq - List utilities related to finding unique items VERSION This document describes version 0.007 of List::Util::Uniq (from Perl distribution List-Util-Uniq), released on 2023-08-14. SYNOPSIS use List::Util::Uniq qw( is_monovalued is_monovalued_ci is_uniq is_uniq_ci uniq_adj uniq_adj_ci uniq_ci dupe dupeint dupenum dupestr dupe_ci ); $res = is_monovalued(qw/a a a/); # => 1 $res = is_monovalued(qw/a b a/); # => 0 $res = is_monovalued_ci(qw/a a A/); # => 1 $res = is_monovalued_ci(qw/a b A/); # => 0 $res = is_uniq(qw/a b a/); # => 0 $res = is_uniq(qw/a b c/); # => 1 $res = is_uniq_ci(qw/a b A/); # => 0 $res = is_uniq_ci(qw/a b c/); # => 1 @res = uniq_adj(1, 4, 4, 3, 1, 1, 2); # => (1, 4, 3, 1, 2) @res = uniq_adj_ci("a", "b", "B", "c", "a"); # => ("a", "b", "c", "a") @res = uniq_ci("a", "b", "B", "c", "a"); # => ("a", "b", "c") @res = dupe("a","b","a","a","b","c"); # => ("a","a","b") @res = dupeint(1,1.2,1.3,2); # => (1.2,1.3) @res = dupenum(1,2,1,1,2,3); # => (1,1,2) @res = dupenum("a",0,0.0,1); # => (0,0.0), because "a" becomes 0 numerically @res = dupestr("a","b","a","a","b","c"); # => ("a","a","b") @res = dupe_ci("a", "b", "B", "c", "a"); # => ("B", "a") DESCRIPTION This module supplements List::Util with functions related to list item's uniqueness. FUNCTIONS None exported by default but exportable. uniq_adj Usage: my @uniq = uniq_adj(@list); Remove *adjacent* duplicates from list, i.e. behave more like Unix utility's uniq instead of List::Util's "uniq" function. Uses string equality test (the "eq" operator). uniq_adj_ci Like "uniq_adj" except case-insensitive. uniq_ci Like "List::Util"' "uniq" ("uniqstr") except case-insensitive. is_uniq Usage: my $is_uniq = is_uniq(@list); Return true when the values in @list is unique (compared string-wise). In theory, knowing whether a list has unique values is faster using this function compared to doing: my @uniq = uniq(@list); @uniq == @list; because of short-circuiting. is_uniq_ci Like "is_uniq" except case-insensitive. is_monovalued Usage: my $is_monovalued = is_monovalued(@list); Examples: is_monovalued(qw/a b c/); # => 0 is_monovalued(qw/a a a/); # => 1 Return true if @list contains only a single value. Returns true for empty list. Undef is coerced to empty string, so is_monovalued(undef) and "is_monovalued(undef, undef)" return true. is_monovalued_ci Like "is_monovalued" except case-insensitive. dupe See "dupestr". dupeint Like "dupestr" but the values are compared as integers. If you only want to list each duplicate elements once, you can do: @uniq_dupes = uniqint(dupeint(@list)); where "uniqint" can be found in List::Util, but the pure-perl version is also provided by this module, for convenience. dupenum Like "dupestr" but the values are compared numerically. If you only want to list each duplicate elements once, you can do: @uniq_dupes = uniqnum(dupenum(@list)); where "uniqnum" can be found in List::Util, but the pure-perl version is also provided by this module, for convenience. dupestr Usage: @dupes = dupestr(@list); Return duplicate elements (the second and subsequence occurrences of each element) in @list. If you only want to list each duplicate elements once, you can do: @uniq_dupes = uniqstr(dupestr(@list)); where "uniqstr" can be found in List::Util, but the pure-perl version is also provided by this module, for convenience. dupe_ci Like "dupe" except case-insensitive. HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . SEE ALSO List::Util Other "List::Util::*" modules. AUTHOR perlancar CONTRIBUTING 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. COPYRIGHT AND LICENSE This software is copyright (c) 2023, 2018 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. BUGS 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.