{"id":7259,"date":"2022-12-20T19:36:01","date_gmt":"2022-12-20T22:36:01","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/listmoreutils-man3\/"},"modified":"2022-12-20T19:36:01","modified_gmt":"2022-12-20T22:36:01","slug":"listmoreutils-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/listmoreutils-man3\/","title":{"rendered":"List::MoreUtils (man3)"},"content":{"rendered":"<h1 align=\"center\">List::MoreUtils<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXPORTS\">EXPORTS<\/a><br \/> <a href=\"#FUNCTIONS\">FUNCTIONS<\/a><br \/> <a href=\"#ENVIRONMENT\">ENVIRONMENT<\/a><br \/> <a href=\"#MAINTENANCE\">MAINTENANCE<\/a><br \/> <a href=\"#CONTRIBUTING\">CONTRIBUTING<\/a><br \/> <a href=\"#BUGS\">BUGS<\/a><br \/> <a href=\"#SUPPORT\">SUPPORT<\/a><br \/> <a href=\"#THANKS\">THANKS<\/a><br \/> <a href=\"#TODO\">TODO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">List::MoreUtils \u2212 Provide the stuff missing in List::Util<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"># import specific functions <br \/> use List::MoreUtils qw(any uniq); <br \/> if ( any { \/foo\/ } uniq @has_duplicates ) { <br \/> # do stuff <br \/> } <br \/> # import everything <br \/> use List::MoreUtils &#8216;:all&#8217;; <br \/> # import by API <br \/> # has &#8220;original&#8221; any\/all\/none\/notall behavior <br \/> use List::MoreUtils &#8216;:like_0.22&#8217;; <br \/> # 0.22 + bsearch <br \/> use List::MoreUtils &#8216;:like_0.24&#8217;; <br \/> # has &#8220;simplified&#8221; any\/all\/none\/notall behavior + (n)sort_by <br \/> use List::MoreUtils &#8216;:like_0.33&#8217;;<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>List::MoreUtils<\/b> provides some trivial but commonly needed functionality on lists which is not going to go into List::Util.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">All of the below functions are implementable in only a couple of lines of Perl code. Using the functions from this module however should give slightly better performance as everything is implemented in C. The pure-Perl implementation of these functions only serves as a fallback in case the C portions of this module couldn\u2019t be compiled on this machine.<\/p>\n<h2>EXPORTS <a name=\"EXPORTS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Default behavior<\/b> <br \/> Nothing by default. To import all of this module\u2019s symbols use the &#8220;:all&#8221; tag. Otherwise functions can be imported by name as usual:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use List::MoreUtils &#8216;:all&#8217;; <br \/> use List::MoreUtils qw{ any firstidx };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Because historical changes to the <small>API<\/small> might make upgrading List::MoreUtils difficult for some projects, the legacy <small>API<\/small> is available via special import tags.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Like version 0.22 (last release with original <small>API<\/small> )<\/b> <br \/> This <small>API<\/small> was available from 2006 to 2009, returning undef for empty lists on &#8220;all&#8221;\/&#8221;any&#8221;\/&#8221;none&#8221;\/&#8221;notall&#8221;:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use List::MoreUtils &#8216;:like_0.22&#8217;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This import tag will import all functions available as of version 0.22. However, it will import &#8220;any_u&#8221; as &#8220;any&#8221;, &#8220;all_u&#8221; as &#8220;all&#8221;, &#8220;none_u&#8221; as &#8220;none&#8221;, and &#8220;notall_u&#8221; as &#8220;notall&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Like version 0.24 (first incompatible change)<\/b> <br \/> This <small>API<\/small> was available from 2010 to 2011. It changed the return value of &#8220;none&#8221; and added the &#8220;bsearch&#8221; function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use List::MoreUtils &#8216;:like_0.24&#8217;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This import tag will import all functions available as of version 0.24. However it will import &#8220;any_u&#8221; as &#8220;any&#8221;, &#8220;all_u&#8221; as &#8220;all&#8221;, and &#8220;notall_u&#8221; as &#8220;notall&#8221;. It will import &#8220;none&#8221; as described in the documentation below (true for empty list).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Like version 0.33 (second incompatible change)<\/b> <br \/> This <small>API<\/small> was available from 2011 to 2014. It is widely used in several <small>CPAN<\/small> modules and thus it\u2019s closest to the current <small>API.<\/small> It changed the return values of &#8220;any&#8221;, &#8220;all&#8221;, and &#8220;notall&#8221;. It added the &#8220;sort_by&#8221; and &#8220;nsort_by&#8221; functions and the &#8220;distinct&#8221; alias for &#8220;uniq&#8221;. It omitted &#8220;bsearch&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use List::MoreUtils &#8216;:like_0.33&#8217;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This import tag will import all functions available as of version 0.33. Note: it will not import &#8220;bsearch&#8221; for consistency with the 0.33 <small>API.<\/small><\/p>\n<h2>FUNCTIONS <a name=\"FUNCTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Junctions<\/b> <i><br \/> Treatment of an empty list<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There are two schools of thought for how to evaluate a junction on an empty list:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"52%\">\n<p>Reduction to an identity (boolean)<\/p>\n<\/td>\n<td width=\"31%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"52%\">\n<p>Result is undefined (three-valued)<\/p>\n<\/td>\n<td width=\"31%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">In the first case, the result of the junction applied to the empty list is determined by a mathematical reduction to an identity depending on whether the underlying comparison is &#8220;or&#8221; or &#8220;and&#8221;. Conceptually:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;any are true&#8221; &#8220;all are true&#8221; <br \/> \u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212 \u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212 <br \/> 2 elements: A || B || 0 A &#038;&#038; B &#038;&#038; 1 <br \/> 1 element: A || 0 A &#038;&#038; 1 <br \/> 0 elements: 0 1<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In the second case, three-value logic is desired, in which a junction applied to an empty list returns &#8220;undef&#8221; rather than true or false<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Junctions with a &#8220;_u&#8221; suffix implement three-valued logic. Those without are boolean.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>all <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>all_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a true value if all items in <small>LIST<\/small> meet the criterion given through <small>BLOCK.<\/small> Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">print &#8220;All values are non\u2212negative&#8221; <br \/> if all { $_ >= 0 } ($x, $y, $z);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For an empty <small>LIST,<\/small> &#8220;all&#8221; returns true (i.e. no values failed the condition) and &#8220;all_u&#8221; returns &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, &#8220;all_u(@list)&#8221; is equivalent to &#8220;@list ? all(@list) : undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Note<\/b>: because Perl treats &#8220;undef&#8221; as false, you must check the return value of &#8220;all_u&#8221; with &#8220;defined&#8221; or you will get the opposite result of what you expect.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>any <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>any_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a true value if any item in <small>LIST<\/small> meets the criterion given through <small>BLOCK.<\/small> Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">print &#8220;At least one non\u2212negative value&#8221; <br \/> if any { $_ >= 0 } ($x, $y, $z);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For an empty <small>LIST,<\/small> &#8220;any&#8221; returns false and &#8220;any_u&#8221; returns &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, &#8220;any_u(@list)&#8221; is equivalent to &#8220;@list ? any(@list) : undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>none <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>none_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Logically the negation of &#8220;any&#8221;. Returns a true value if no item in <small>LIST<\/small> meets the criterion given through <small>BLOCK.<\/small> Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">print &#8220;No non\u2212negative values&#8221; <br \/> if none { $_ >= 0 } ($x, $y, $z);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For an empty <small>LIST,<\/small> &#8220;none&#8221; returns true (i.e. no values failed the condition) and &#8220;none_u&#8221; returns &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, &#8220;none_u(@list)&#8221; is equivalent to &#8220;@list ? none(@list) : undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Note<\/b>: because Perl treats &#8220;undef&#8221; as false, you must check the return value of &#8220;none_u&#8221; with &#8220;defined&#8221; or you will get the opposite result of what you expect.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>notall <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>notall_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Logically the negation of &#8220;all&#8221;. Returns a true value if not all items in <small>LIST<\/small> meet the criterion given through <small>BLOCK.<\/small> Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">print &#8220;Not all values are non\u2212negative&#8221; <br \/> if notall { $_ >= 0 } ($x, $y, $z);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For an empty <small>LIST,<\/small> &#8220;notall&#8221; returns false and &#8220;notall_u&#8221; returns &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, &#8220;notall_u(@list)&#8221; is equivalent to &#8220;@list ? notall(@list) : undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>one <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>one_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a true value if precisely one item in <small>LIST<\/small> meets the criterion given through <small>BLOCK.<\/small> Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">print &#8220;Precisely one value defined&#8221; <br \/> if one { defined($_) } @list;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns false otherwise.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For an empty <small>LIST,<\/small> &#8220;one&#8221; returns false and &#8220;one_u&#8221; returns &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The expression &#8220;one BLOCK LIST&#8221; is almost equivalent to &#8220;1 == true BLOCK LIST&#8221;, except for short-cutting. Evaluation of <small>BLOCK<\/small> will immediately stop at the second true value.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Transformation<\/b> <i><br \/> apply <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Applies <small>BLOCK<\/small> to each item in <small>LIST<\/small> and returns a list of the values after <small>BLOCK<\/small> has been applied. In scalar context, the last element is returned. This function is similar to &#8220;map&#8221; but will not modify the elements of the input list:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = (1 .. 4); <br \/> my @mult = apply { $_ *= 2 } @list; <br \/> print &#8220;@list = @listn&#8221;; <br \/> print &#8220;@mult = @multn&#8221;; <br \/> __END__ <br \/> @list = 1 2 3 4 <br \/> @mult = 2 4 6 8<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Think of it as syntactic sugar for<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">for (my @mult = @list) { $_ *= 2 }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>insert_after <small>BLOCK VALUE LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Inserts <small>VALUE<\/small> after the first item in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is true. Sets $_ for each item in <small>LIST<\/small> in turn.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = qw\/This is a list\/; <br \/> insert_after { $_ eq &#8220;a&#8221; } &#8220;longer&#8221; => @list; <br \/> print &#8220;@list&#8221;; <br \/> __END__ <br \/> This is a longer list<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>insert_after_string <small>STRING VALUE LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Inserts <small>VALUE<\/small> after the first item in <small>LIST<\/small> which is equal to <small>STRING.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = qw\/This is a list\/; <br \/> insert_after_string &#8220;a&#8221;, &#8220;longer&#8221; => @list; <br \/> print &#8220;@list&#8221;; <br \/> __END__ <br \/> This is a longer list<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>pairwise <small>BLOCK ARRAY1 ARRAY2<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Evaluates <small>BLOCK<\/small> for each pair of elements in <small>ARRAY1<\/small> and <small>ARRAY2<\/small> and returns a new list consisting of <small>BLOCK<\/small> \u2019s return values. The two elements are set to $a and $b. Note that those two are aliases to the original value so changing them will modify the input arrays.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@a = (1 .. 5); <br \/> @b = (11 .. 15); <br \/> @x = pairwise { $a + $b } @a, @b; # returns 12, 14, 16, 18, 20 <br \/> # mesh with pairwise <br \/> @a = qw\/a b c\/; <br \/> @b = qw\/1 2 3\/; <br \/> @x = pairwise { ($a, $b) } @a, @b; # returns a, 1, b, 2, c, 3<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>mesh <small>ARRAY1 ARRAY2<\/small> [ <small>ARRAY3 &#8230;<\/small> ]<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>zip <small>ARRAY1 ARRAY2<\/small> [ <small>ARRAY3 &#8230;<\/small> ]<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list consisting of the first elements of each array, then the second, then the third, etc, until all arrays are exhausted.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Examples:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@x = qw\/a b c d\/; <br \/> @y = qw\/1 2 3 4\/; <br \/> @z = mesh @x, @y; # returns a, 1, b, 2, c, 3, d, 4 <br \/> @a = (&#8216;x&#8217;); <br \/> @b = (&#8216;1&#8217;, &#8216;2&#8217;); <br \/> @c = qw\/zip zap zot\/; <br \/> @d = mesh @a, @b, @c; # x, 1, zip, undef, 2, zap, undef, undef, zot<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;zip&#8221; is an alias for &#8220;mesh&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>zip6<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>zip_unflatten<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list of arrays consisting of the first elements of each array, then the second, then the third, etc, until all arrays are exhausted.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@x = qw\/a b c d\/; <br \/> @y = qw\/1 2 3 4\/; <br \/> @z = zip6 @x, @y; # returns [a, 1], [b, 2], [c, 3], [d, 4] <br \/> @a = (&#8216;x&#8217;); <br \/> @b = (&#8216;1&#8217;, &#8216;2&#8217;); <br \/> @c = qw\/zip zap zot\/; <br \/> @d = zip6 @a, @b, @c; # [x, 1, zip], [undef, 2, zap], [undef, undef, zot]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;zip_unflatten&#8221; is an alias for &#8220;zip6&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>listcmp <small>ARRAY0 ARRAY1<\/small> [ <small>ARRAY2 &#8230;<\/small> ]<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns an associative list of elements and every <i>id<\/i> of the list it was found in. Allows easy implementation of @a &#038; @b, @a | @b, @a ^ @b and so on. Undefined entries in any given array are skipped.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @a = qw(one two three four five six seven eight nine ten eleven twelve thirteen); <br \/> my @b = qw(two three five seven eleven thirteen seventeen); <br \/> my @c = qw(one one two three five eight thirteen twentyone); <br \/> my %cmp = listcmp @a, @b, @c; # returns (one => [0, 2], two => [0, 1, 2], three => [0, 1, 2], four => [0], &#8230;) <br \/> my @seq = (1, 2, 3); <br \/> my @prim = (undef, 2, 3, 5); <br \/> my @fib = (1, 1, 2); <br \/> my %cmp = listcmp @seq, @prim, @fib; <br \/> # returns ( 1 => [0, 2], 2 => [0, 1, 2], 3 => [0, 1], 5 => [1] )<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>arrayify LIST[,LIST[,LIST&#8230;]]<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list consisting of each element of given arrays. Recursive arrays are flattened, too.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@a = (1, [[2], 3], 4, [5], 6, [7], 8, 9); <br \/> @l = arrayify @a; # returns 1, 2, 3, 4, 5, 6, 7, 8, 9<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>uniq <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>distinct <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a new list by stripping duplicate values in <small>LIST<\/small> by comparing the values as hash keys, except that undef is considered separate from \u2019\u2019. The order of elements in the returned list is the same as in <small>LIST.<\/small> In scalar context, returns the number of unique elements in <small>LIST.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 <br \/> my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 <br \/> # returns &#8220;Mike&#8221;, &#8220;Michael&#8221;, &#8220;Richard&#8221;, &#8220;Rick&#8221; <br \/> my @n = distinct &#8220;Mike&#8221;, &#8220;Michael&#8221;, &#8220;Richard&#8221;, &#8220;Rick&#8221;, &#8220;Michael&#8221;, &#8220;Rick&#8221; <br \/> # returns &#8220;A8&#8221;, &#8220;&#8221;, undef, &#8220;A5&#8221;, &#8220;S1&#8221; <br \/> my @s = distinct &#8220;A8&#8221;, &#8220;&#8221;, undef, &#8220;A5&#8221;, &#8220;S1&#8221;, &#8220;A5&#8221;, &#8220;A8&#8221; <br \/> # returns &#8220;Giulia&#8221;, &#8220;Giulietta&#8221;, undef, &#8220;&#8221;, 156, &#8220;GTA&#8221;, &#8220;GTV&#8221;, 159, &#8220;Brera&#8221;, &#8220;4C&#8221; <br \/> my @w = uniq &#8220;Giulia&#8221;, &#8220;Giulietta&#8221;, undef, &#8220;&#8221;, 156, &#8220;GTA&#8221;, &#8220;GTV&#8221;, 159, &#8220;Brera&#8221;, &#8220;4C&#8221;, &#8220;Giulietta&#8221;, &#8220;Giulia&#8221;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;distinct&#8221; is an alias for &#8220;uniq&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>RT#49800<\/b> can be used to give feedback about this behavior.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>singleton <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a new list by stripping values in <small>LIST<\/small> occurring more than once by comparing the values as hash keys, except that undef is considered separate from \u2019\u2019. The order of elements in the returned list is the same as in <small>LIST.<\/small> In scalar context, returns the number of elements occurring only once in <small>LIST.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = singleton 1,1,2,2,3,4,5 # returns 3 4 5<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>duplicates <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a new list by stripping values in <small>LIST<\/small> occurring less than twice by comparing the values as hash keys, except that undef is considered separate from \u2019\u2019. The order of elements in the returned list is the same as in <small>LIST.<\/small> In scalar context, returns the number of elements occurring more than once in <small>LIST.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @y = duplicates 1,1,2,4,7,2,3,4,6,9; #returns 1,2,4<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>frequency <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns an associative list of distinct values and the corresponding frequency.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @f = frequency values %radio_nrw; # returns ( <br \/> # &#8216;Deutschlandfunk (DLF)&#8217; => 9, &#8216;WDR 3&#8217; => 10, <br \/> # &#8216;WDR 4&#8217; => 11, &#8216;WDR 5&#8217; => 14, &#8216;WDR Eins Live&#8217; => 14, <br \/> # &#8216;Deutschlandradio Kultur&#8217; => 8,&#8230;)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>occurrences <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a new list of frequencies and the corresponding values from <small>LIST.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @o = occurrences ((1) x 3, (2) x 4, (3) x 2, (4) x 7, (5) x 2, (6) x 4); <br \/> # @o = (undef, undef, [3, 5], [1], [2, 6], undef, undef, [4]);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>mode <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the modal value of <small>LIST.<\/small> In scalar context, just the modal value is returned, in list context all probes occurring <i>modal<\/i> times are returned, too.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @m = mode ((1) x 3, (2) x 4, (3) x 2, (4) x 7, (5) x 2, (6) x 4, (7) x 3, (8) x 7); <br \/> # @m = (7, 4, 8) \u2212 bimodal LIST<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>slide <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The function &#8220;slide&#8221; operates on pairs of list elements like:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @s = slide { &#8220;$a and $b&#8221; } (0..3); <br \/> # @s = (&#8220;0 and 1&#8221;, &#8220;1 and 2&#8221;, &#8220;2 and 3&#8221;)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The idea behind this function is a kind of magnifying glass that is moved along a list and calls &#8220;BLOCK&#8221; every time the next list item is reached.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Partitioning<\/b> <i><br \/> after <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list of the values of <small>LIST<\/small> after (and not including) the point where <small>BLOCK<\/small> returns a true value. Sets $_ for each element in <small>LIST<\/small> in turn.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@x = after { $_ % 5 == 0 } (1..9); # returns 6, 7, 8, 9<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>after_incl <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Same as &#8220;after&#8221; but also includes the element for which <small>BLOCK<\/small> is true.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>before <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list of values of <small>LIST<\/small> up to (and not including) the point where <small>BLOCK<\/small> returns a true value. Sets $_ for each element in <small>LIST<\/small> in turn.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>before_incl <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Same as &#8220;before&#8221; but also includes the element for which <small>BLOCK<\/small> is true.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>part <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Partitions <small>LIST<\/small> based on the return value of <small>BLOCK<\/small> which denotes into which partition the current value is put.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list of the partitions thusly created. Each partition created is a reference to an array.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my $i = 0; <br \/> my @part = part { $i++ % 2 } 1 .. 8; # returns [1, 3, 5, 7], [2, 4, 6, 8]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">You can have a sparse list of partitions as well where non-set partitions will be undef:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @part = part { 2 } 1 .. 10; # returns undef, undef, [ 1 .. 10 ]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Be careful with negative values, though:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @part = part { \u22121 } 1 .. 10; <br \/> __END__ <br \/> Modification of non\u2212creatable array value attempted, subscript \u22121 &#8230;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Negative values are only ok when they refer to a partition previously created:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @idx = ( 0, 1, \u22121 ); <br \/> my $i = 0; <br \/> my @part = part { $idx[$i++ % 3] } 1 .. 8; # [1, 4, 7], [2, 3, 5, 6, 8]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>samples <small>COUNT LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a new list containing <small>COUNT<\/small> random samples from <small>LIST.<\/small> Is similar to &#8220;shuffle&#8221; in List::Util, but stops after <small>COUNT.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@r = samples 10, 1..10; # same as shuffle <br \/> @r2 = samples 5, 1..10; # gives 5 values from 1..10;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Iteration<\/b> <i><br \/> each_array <small>ARRAY1 ARRAY2 &#8230;<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Creates an array iterator to return the elements of the list of arrays <small>ARRAY1, ARRAY2<\/small> throughout ARRAYn in turn. That is, the first time it is called, it returns the first element of each array. The next time, it returns the second elements. And so on, until all elements are exhausted.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is useful for looping over more than one array at once:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my $ea = each_array(@a, @b, @c); <br \/> while ( my ($a, $b, $c) = $ea\u2212>() ) { &#8230;. }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The iterator returns the empty list when it reached the end of all arrays.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the iterator is passed an argument of \u2019&#8221;index&#8221;\u2019, then it returns the index of the last fetched set of values, as a scalar.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>each_arrayref <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Like each_array, but the arguments are references to arrays, not the plain arrays.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>natatime <small>EXPR, LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Creates an array iterator, for looping over an array in chunks of $n items at a time. (n at a time, get it?). An example is probably a better explanation than I could give in words.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Example:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = (&#8216;a&#8217; .. &#8216;g&#8217;); <br \/> my $it = natatime 3, @x; <br \/> while (my @vals = $it\u2212>()) <br \/> { <br \/> print &#8220;@valsn&#8221;; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This prints<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">a b c <br \/> d e f <br \/> g<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>slideatatime <small>STEP, WINDOW, LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Creates an array iterator, for looping over an array in chunks of &#8220;$windows\u2212size&#8221; items at a time.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The idea behind this function is a kind of magnifying glass (finer controllable compared to &#8220;slide&#8221;) that is moved along a list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Example:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = (&#8216;a&#8217; .. &#8216;g&#8217;); <br \/> my $it = slideatatime 2, 3, @x; <br \/> while (my @vals = $it\u2212>()) <br \/> { <br \/> print &#8220;@valsn&#8221;; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This prints<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">a b c <br \/> c d e <br \/> e f g <br \/> g<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Searching<\/b> <i><br \/> firstval <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>first_value <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the first element in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Each element of <small>LIST<\/small> is set to $_ in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;first_value&#8221; is an alias for &#8220;firstval&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>onlyval <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>only_value <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the only element in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Sets $_ for each item in <small>LIST<\/small> in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;only_value&#8221; is an alias for &#8220;onlyval&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>lastval <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>last_value <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the last value in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Each element of <small>LIST<\/small> is set to $_ in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;last_value&#8221; is an alias for &#8220;lastval&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>firstres <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>first_result <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the result of <small>BLOCK<\/small> for the first element in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Each element of <small>LIST<\/small> is set to $_ in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;first_result&#8221; is an alias for &#8220;firstres&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>onlyres <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>only_result <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the result of <small>BLOCK<\/small> for the first element in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Sets $_ for each item in <small>LIST<\/small> in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;only_result&#8221; is an alias for &#8220;onlyres&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>lastres <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>last_result <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the result of <small>BLOCK<\/small> for the last element in <small>LIST<\/small> for which <small>BLOCK<\/small> evaluates to true. Each element of <small>LIST<\/small> is set to $_ in turn. Returns &#8220;undef&#8221; if no such element has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;last_result&#8221; is an alias for &#8220;lastres&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>indexes <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Evaluates <small>BLOCK<\/small> for each element in <small>LIST<\/small> (assigned to $_) and returns a list of the indices of those elements for which <small>BLOCK<\/small> returned a true value. This is just like &#8220;grep&#8221; only that it returns indices instead of values:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@x = indexes { $_ % 2 == 0 } (1..10); # returns 1, 3, 5, 7, 9<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>firstidx <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>first_index <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of the first element in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is true. Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = (1, 4, 3, 2, 4, 6); <br \/> printf &#8220;item with index %i in list is 4&#8221;, firstidx { $_ == 4 } @list; <br \/> __END__ <br \/> item with index 1 in list is 4<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns &#8220;\u22121&#8221; if no such item could be found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;first_index&#8221; is an alias for &#8220;firstidx&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>onlyidx <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>only_index <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of the only element in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is true. Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = (1, 3, 4, 3, 2, 4); <br \/> printf &#8220;uniqe index of item 2 in list is %i&#8221;, onlyidx { $_ == 2 } @list; <br \/> __END__ <br \/> unique index of item 2 in list is 4<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns &#8220;\u22121&#8221; if either no such item or more than one of these has been found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;only_index&#8221; is an alias for &#8220;onlyidx&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>lastidx <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>last_index <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of the last element in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is true. Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @list = (1, 4, 3, 2, 4, 6); <br \/> printf &#8220;item with index %i in list is 4&#8221;, lastidx { $_ == 4 } @list; <br \/> __END__ <br \/> item with index 4 in list is 4<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns &#8220;\u22121&#8221; if no such item could be found.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;last_index&#8221; is an alias for &#8220;lastidx&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Sorting<\/b> <i><br \/> sort_by <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the list of values sorted according to the string values returned by the <small>KEYFUNC<\/small> block or function. A typical use of this may be to sort objects according to the string value of some accessor, such as<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">sort_by { $_\u2212>name } @people<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The key function is called in scalar context, being passed each value in turn as both $_ and the only argument in the parameters, @_. The values are then sorted according to string comparisons on the values returned. This is equivalent to<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">sort { $a\u2212>name cmp $b\u2212>name } @people<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">except that it guarantees the name accessor will be executed only once per value. One interesting use-case is to sort strings which may have numbers embedded in them &#8220;naturally&#8221;, rather than lexically.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">sort_by { s\/(d+)\/sprintf &#8220;%09d&#8221;, $1\/eg; $_ } @strings<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This sorts strings by generating sort keys which zero-pad the embedded numbers to some level (9 digits in this case), helping to ensure the lexical sort puts them in the correct order.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>nsort_by <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Similar to sort_by but compares its key values numerically.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>qsort <small>BLOCK ARRAY<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This sorts the given array <b>in place<\/b> using the given compare code. Except for tiny compare code like &#8220;$a <=> $b&#8221;, qsort is much faster than Perl\u2019s &#8220;sort&#8221; depending on the version.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Compared 5.8 and 5.26:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @rl; <br \/> for(my $i = 0; $i < 1E6; ++$i) { push @rl, rand(1E5) } <br \/> my $idx; <br \/> sub ext_cmp { $_[0] <=> $_[1] } <br \/> cmpthese( \u221260, { <br \/> &#8216;qsort&#8217; => sub { <br \/> my @qrl = @rl; <br \/> qsort { ext_cmp($a, $b) } @qrl; <br \/> $idx = bsearchidx { ext_cmp($_, $rl[0]) } @qrl <br \/> }, <br \/> &#8216;reverse qsort&#8217; => sub { <br \/> my @qrl = @rl; <br \/> qsort { ext_cmp($b, $a) } @qrl; <br \/> $idx = bsearchidx { ext_cmp($rl[0], $_) } @qrl <br \/> }, <br \/> &#8216;sort&#8217; => sub { <br \/> my @srl = @rl; <br \/> @srl = sort { ext_cmp($a, $b) } @srl; <br \/> $idx = bsearchidx { ext_cmp($_, $rl[0]) } @srl <br \/> }, <br \/> &#8216;reverse sort&#8217; => sub { <br \/> my @srl = @rl; <br \/> @srl = sort { ext_cmp($b, $a) } @srl; <br \/> $idx = bsearchidx { ext_cmp($rl[0], $_) } @srl <br \/> }, <br \/> });<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">5.8 results<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">s\/iter reverse sort sort reverse qsort qsort <br \/> reverse sort 6.21 \u2212\u2212 \u22120% \u22128% \u221210% <br \/> sort 6.19 0% \u2212\u2212 \u22127% \u221210% <br \/> reverse qsort 5.73 8% 8% \u2212\u2212 \u22122% <br \/> qsort 5.60 11% 11% 2% \u2212\u2212<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">5.26 results<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">s\/iter reverse sort sort reverse qsort qsort <br \/> reverse sort 4.54 \u2212\u2212 \u22120% \u221296% \u221296% <br \/> sort 4.52 0% \u2212\u2212 \u221296% \u221296% <br \/> reverse qsort 0.203 2139% 2131% \u2212\u2212 \u221219% <br \/> qsort 0.164 2666% 2656% 24% \u2212\u2212<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Use it where external data sources might have to be compared (think of Unix::Statgrab &#8220;tables&#8221;).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;qsort&#8221; is available from List::MoreUtils::XS only. It\u2019s insane to maintain a wrapper around Perl\u2019s sort nor having a pure Perl implementation. One could create a flip-book in same speed as <small>PP<\/small> runs a qsort.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Searching in sorted Lists<\/b> <i><br \/> bsearch <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Performs a binary search on <small>LIST<\/small> which must be a sorted list of values. <small>BLOCK<\/small> must return a negative value if the current element (stored in $_) is smaller, a positive value if it is bigger and zero if it matches.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a boolean value in scalar context. In list context, it returns the element if it was found, otherwise the empty list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bsearchidx <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bsearch_index <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Performs a binary search on <small>LIST<\/small> which must be a sorted list of values. <small>BLOCK<\/small> must return a negative value if the current element (stored in $_) is smaller, a positive value if it is bigger and zero if it matches.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of found element, otherwise &#8220;\u22121&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;bsearch_index&#8221; is an alias for &#8220;bsearchidx&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>lower_bound <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of the first element in <small>LIST<\/small> which does not compare <i>less than val<\/i>. Technically it\u2019s the first element in <small>LIST<\/small> which does not return a value below zero when passed to <small>BLOCK.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@ids = (1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 11, 13, 13, 13, 17); <br \/> $lb = lower_bound { $_ <=> 2 } @ids; # returns 2 <br \/> $lb = lower_bound { $_ <=> 4 } @ids; # returns 10<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">lower_bound has a complexity of O(log n).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>upper_bound <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the index of the first element in <small>LIST<\/small> which does not compare <i>greater than val<\/i>. Technically it\u2019s the first element in <small>LIST<\/small> which does not return a value below or equal to zero when passed to <small>BLOCK.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@ids = (1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 11, 13, 13, 13, 17); <br \/> $lb = upper_bound { $_ <=> 2 } @ids; # returns 4 <br \/> $lb = upper_bound { $_ <=> 4 } @ids; # returns 14<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">upper_bound has a complexity of O(log n).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>equal_range <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a pair of indices containing the lower_bound and the upper_bound.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Operations on sorted Lists<\/b> <i><br \/> binsert <small>BLOCK ITEM LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bsearch_insert <small>BLOCK ITEM LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Performs a binary search on <small>LIST<\/small> which must be a sorted list of values. <small>BLOCK<\/small> must return a negative value if the current element (stored in $_) is smaller, a positive value if it is bigger and zero if it matches.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>ITEM<\/small> is inserted at the index where the <small>ITEM<\/small> should be placed (based on above search). That means, it\u2019s inserted before the next bigger element.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@l = (2,3,5,7); <br \/> binsert { $_ <=> 4 } 4, @l; # @l = (2,3,4,5,7) <br \/> binsert { $_ <=> 6 } 42, @l; # @l = (2,3,4,42,7)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">You take care that the inserted element matches the compare result.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bremove <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bsearch_remove <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Performs a binary search on <small>LIST<\/small> which must be a sorted list of values. <small>BLOCK<\/small> must return a negative value if the current element (stored in $_) is smaller, a positive value if it is bigger and zero if it matches.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The item at the found position is removed and returned.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@l = (2,3,4,5,7); <br \/> bremove { $_ <=> 4 }, @l; # @l = (2,3,5,7);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Counting and calculation<\/b> <i><br \/> true <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Counts the number of elements in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is true. Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">printf &#8220;%i item(s) are defined&#8221;, true { defined($_) } @list;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>false <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Counts the number of elements in <small>LIST<\/small> for which the criterion in <small>BLOCK<\/small> is false. Sets $_ for each item in <small>LIST<\/small> in turn:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">printf &#8220;%i item(s) are not defined&#8221;, false { defined($_) } @list;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>reduce_0 <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Reduce <small>LIST<\/small> by calling <small>BLOCK<\/small> in scalar context for each element of <small>LIST.<\/small> $a contains the progressional result and is initialized with 0. $b contains the current processed element of <small>LIST<\/small> and $_ contains the index of the element in $b.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The idea behind reduce_0 is <b>summation<\/b> (addition of a sequence of numbers).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>reduce_1 <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Reduce <small>LIST<\/small> by calling <small>BLOCK<\/small> in scalar context for each element of <small>LIST.<\/small> $a contains the progressional result and is initialized with 1. $b contains the current processed element of <small>LIST<\/small> and $_ contains the index of the element in $b.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The idea behind reduce_1 is product of a sequence of numbers.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>reduce_u <small>BLOCK LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Reduce <small>LIST<\/small> by calling <small>BLOCK<\/small> in scalar context for each element of <small>LIST.<\/small> $a contains the progressional result and is uninitialized. $b contains the current processed element of <small>LIST<\/small> and $_ contains the index of the element in $b.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This function has been added if one might need the extra of the index value but need an individual initialization.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Use with caution<\/b>: In most cases &#8220;reduce&#8221; in List::Util will do the job better.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>minmax <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Calculates the minimum and maximum of <small>LIST<\/small> and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if <small>LIST<\/small> was empty.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;minmax&#8221; algorithm differs from a naive iteration over the list where each element is compared to two values being the so far calculated min and max value in that it only requires 3n\/2 \u2212 2 comparisons. Thus it is the most efficient possible algorithm.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">However, the Perl implementation of it has some overhead simply due to the fact that there are more lines of Perl code involved. Therefore, <small>LIST<\/small> needs to be fairly big in order for &#8220;minmax&#8221; to win over a naive implementation. This limitation does not apply to the <small>XS<\/small> version.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>minmaxstr <small>LIST<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Computes the minimum and maximum of <small>LIST<\/small> using string compare and returns a two element list with the first element being the minimum and the second the maximum. Returns the empty list if <small>LIST<\/small> was empty.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The implementation is similar to &#8220;minmax&#8221;.<\/p>\n<h2>ENVIRONMENT <a name=\"ENVIRONMENT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">When &#8220;LIST_MOREUTILS_PP&#8221; is set, the module will always use the pure-Perl implementation and not the <small>XS<\/small> one. This environment variable is really just there for the test-suite to force testing the Perl implementation, and possibly for reporting of bugs. I don\u2019t see any reason to use it in a production environment.<\/p>\n<h2>MAINTENANCE <a name=\"MAINTENANCE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The maintenance goal is to preserve the documented semantics of the <small>API<\/small> ; bug fixes that bring actual behavior in line with semantics are allowed. New <small>API<\/small> functions may be added over time. If a backwards incompatible change is unavoidable, we will attempt to provide support for the legacy <small>API<\/small> using the same export tag mechanism currently in place.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This module attempts to use few non-core dependencies. Non-core configuration and testing modules will be bundled when reasonable; run-time dependencies will be added only if they deliver substantial benefit.<\/p>\n<h2>CONTRIBUTING <a name=\"CONTRIBUTING\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">While contributions are appreciated, a contribution should not cause more effort for the maintainer than the contribution itself saves (see Open Source Contribution Etiquette <http:\/\/tirania.org\/blog\/archive\/2010\/Dec-31.html>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To get more familiar where help could be needed \u2212 see List::MoreUtils::Contributing.<\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">There is a problem with a bug in 5.6.x perls. It is a syntax error to write things like:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = apply { s\/foo\/bar\/ } qw{ foo bar baz };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It has to be written as either<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = apply { s\/foo\/bar\/ } &#8216;foo&#8217;, &#8216;bar&#8217;, &#8216;baz&#8217;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">or<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">my @x = apply { s\/foo\/bar\/ } my @dummy = qw\/foo bar baz\/;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Perl 5.5.x and Perl 5.8.x don\u2019t suffer from this limitation.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If you have a functionality that you could imagine being in this module, please drop me a line. This module\u2019s policy will be less strict than List::Util\u2019s when it comes to additions as it isn\u2019t a core module.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When you report bugs, it would be nice if you could additionally give me the output of your program with the environment variable &#8220;LIST_MOREUTILS_PP&#8221; set to a true value. That way I know where to look for the problem (in <small>XS,<\/small> pure-Perl or possibly both).<\/p>\n<h2>SUPPORT <a name=\"SUPPORT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Bugs should always be submitted via the <small>CPAN<\/small> bug tracker.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">You can find documentation for this module with the perldoc command.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">perldoc List::MoreUtils<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">You can also look for information at:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"40%\">\n<p style=\"margin-top: 1em\"><small>RT: CPAN<\/small> \u2019s request tracker<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><https:\/\/rt.cpan.org\/Dist\/Display.html?Name=List\u2212MoreUtils><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"58%\">\n<p style=\"margin-top: 1em\">AnnoCPAN: Annotated <small>CPAN<\/small> documentation<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><http:\/\/annocpan.org\/dist\/List\u2212MoreUtils><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"18%\">\n<p style=\"margin-top: 1em\"><small>CPAN<\/small> Ratings<\/p>\n<\/td>\n<td width=\"65%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><http:\/\/cpanratings.perl.org\/dist\/List\u2212MoreUtils><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\">MetaCPAN<\/p>\n<\/td>\n<td width=\"71%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><https:\/\/metacpan.org\/release\/List\u2212MoreUtils><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"17%\">\n<p style=\"margin-top: 1em\"><small>CPAN<\/small> Search<\/p>\n<\/td>\n<td width=\"66%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><http:\/\/search.cpan.org\/dist\/List\u2212MoreUtils\/><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"21%\">\n<p style=\"margin-top: 1em\">Git Repository<\/p>\n<\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\"><https:\/\/github.com\/perl5\u2212utils\/List\u2212MoreUtils><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Where can I go for help?<\/b> <br \/> If you have a bug report, a patch or a suggestion, please open a new report ticket at <small>CPAN<\/small> (but please check previous reports first in case your issue has already been addressed) or open an issue on GitHub.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Report tickets should contain a detailed description of the bug or enhancement request and at least an easily verifiable way of reproducing the issue or fix. Patches are always welcome, too \u2212 and it\u2019s cheap to send pull-requests on GitHub. Please keep in mind that code changes are more likely accepted when they\u2019re bundled with an approving test.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If you think you\u2019ve found a bug then please read &#8220;How to Report Bugs Effectively&#8221; by Simon Tatham: <http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/bugs.html>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Where can I go for help with a concrete version?<\/b> <br \/> Bugs and feature requests are accepted against the latest version only. To get patches for earlier versions, you need to get an agreement with a developer of your choice \u2212 who may or not report the issue and a suggested fix upstream (depends on the license you have chosen).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Business support and maintenance<\/b> <br \/> Generally, in volunteered projects, there is no right for support. While every maintainer is happy to improve the provided software, spare time is limited.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For those who have a use case which requires guaranteed support, one of the maintainers should be hired or contracted. For business support you can contact Jens via his <small>CPAN<\/small> email address rehsackATcpan.org. Please keep in mind that business support is neither available for free nor are you eligible to receive any support based on the license distributed with this package.<\/p>\n<h2>THANKS <a name=\"THANKS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tassilo von Parseval<\/b> <br \/> Credits go to a number of people: Steve Purkis for giving me namespace advice and James Keenan and Terrence Branno for their effort of keeping the <small>CPAN<\/small> tidier by making List::Utils obsolete.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Brian McCauley suggested the inclusion of <b>apply()<\/b> and provided the pure-Perl implementation for it.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Eric J. Roode asked me to add all functions from his module &#8220;List::MoreUtil&#8221; into this one. With minor modifications, the pure-Perl implementations of those are by him.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The bunch of people who almost immediately pointed out the many problems with the glitchy 0.07 release (Slaven Rezic, Ron Savage, <small>CPAN<\/small> testers).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A particularly nasty memory leak was spotted by Thomas A. Lowery.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Lars Thegler made me aware of problems with older Perl versions.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Anno Siegel de-orphaned <b>each_arrayref()<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">David Filmer made me aware of a problem in each_arrayref that could ultimately lead to a segfault.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ricardo Signes suggested the inclusion of <b>part()<\/b> and provided the Perl-implementation.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Robin Huston kindly fixed a bug in perl\u2019s <small>MULTICALL API<\/small> to make the XS-implementation of <b>part()<\/b> work.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Jens Rehsack<\/b> <br \/> Credits goes to all people contributing feedback during the v0.400 development releases.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Special thanks goes to David Golden who spent a lot of effort to develop a design to support current state of <small>CPAN<\/small> as well as ancient software somewhere in the dark. He also contributed a lot of patches to refactor the <small>API<\/small> frontend to welcome any user of List::MoreUtils \u2212 from ancient past to recently last used.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Toby Inkster provided a lot of useful feedback for sane importer code and was a nice sounding board for <small>API<\/small> discussions.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Peter Rabbitson provided a sane git repository setup containing entire package history.<\/p>\n<h2>TODO <a name=\"TODO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A pile of requests from other people is still pending further processing in my mailbox. This includes:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p style=\"margin-top: 1em\">delete_index<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>random_item<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>random_item_delete_index<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>list_diff_hash<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>list_diff_inboth<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>list_diff_infirst<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"37%\">\n<p>list_diff_insecond<\/p>\n<\/td>\n<td width=\"46%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">These were all suggested by Dan Muey.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p style=\"margin-top: 1em\">listify<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">Always return a flat list when either a simple scalar value was passed or an array-reference. Suggested by Mark Summersault.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">List::Util, List::AllUtils, List::UtilsBy<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Jens Rehsack <rehsack <small>AT<\/small> cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Adam Kennedy <adamk@cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tassilo von Parseval <tassilo.von.parseval@rwth\u2212aachen.de><\/p>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Some parts copyright 2011 Aaron Crane.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 2004 \u2212 2010 by Tassilo von Parseval<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 2013 \u2212 2017 by Jens Rehsack<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">All code added with 0.417 or later is licensed under the Apache License, Version 2.0 (the &#8220;License&#8221;); you may not use this file except in compliance with the License. You may obtain a copy of the License at<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">http:\/\/www.apache.org\/licenses\/LICENSE\u22122.0<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &#8221; <small>AS IS&#8221; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,<\/small> either express or implied. See the License for the specific language governing permissions and limitations under the License.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">All code until 0.416 is licensed under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  List::MoreUtils \u2212 Provide the stuff missing in List::Util <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3584,3007],"class_list":["post-7259","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-listmoreutils","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7259"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7259\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}