CINXE.COM

List::Util - A selection of general-utility list subroutines - metacpan.org

<!DOCTYPE html> <html lang="en-US"> <head> <title>List::Util - A selection of general-utility list subroutines - metacpan.org</title> <link rel="preload" as="fetch" href="/account/login_status" crossorigin="anonymous" /> <link href="/assets/style-XFEQ536G.css" rel="stylesheet" type="text/css"> <script src="/assets/main-WXBSEDQJ.js" type="module"></script> <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Scalar-List-Utils - MetaCPAN" href="/dist/Scalar-List-Utils/releases.rss" /> <link rel="canonical" href="https://metacpan.org/pod/List::Util" /> <meta name="description" content="A selection of general-utility list subroutines" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5"> <link rel="shortcut icon" href="/static/icons/favicon.ico"> <link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png"> <link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN"> <script async src="https://perl-ads.perlhacks.com/perl-ads.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-E82Q2V8LVD"></script> <meta property="og:site_name" content="MetaCPAN" /> <meta name="twitter:site" content="@metacpan" /> <meta property="og:type" content="article" /> <meta name="twitter:card" content="summary" /> <meta property="og:url" content="https://metacpan.org/pod/List::Util" /> <meta property="og:title" content="List::Util" /> <meta property="og:description" content="A selection of general-utility list subroutines" /> <meta property="og:image" content="https://metacpan.org/static/images/dots.png" /> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="header-logo-large hidden-xs"> <a href="/" tabindex="0"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#logo" /> </svg> </a> </div> <div class="header-logo-icon visible-xs"> <a href="/"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#dots" /> </svg> </a> </div> <ul class="nav navbar-nav menu-items hidden-xs hidden-sm"> <li><a href="/about">About</a></li> <li><a href="/about/sponsors">Sponsor</a></li> <li><a href="https://grep.metacpan.org/">grep::cpan</a></li> <li><a href="/recent">Recent</a></li> <li><a href="/about/faq">FAQ</a></li> <li><a href="/tools">Tools</a></li> <li><a href="https://fastapi.metacpan.org/">API</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <button type="button" class="searchbar-btn visible-xs visible-sm"> <i class="fa fa-search button-fa-icon"></i> </button> <form action="/search" class="searchbar-form visible-md visible-lg search-form form-horizontal"> <input type="hidden" name="size" id="metacpan_search-size" value="20"> <div class="form-group"> <div class="search-group"> <i class="fa fa-search"></i> <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value=""> </div> </div> </form> <li class="icon-slidepanel visible-xs visible-sm"> <button data-toggle="slidepanel" data-target=".slidepanel"> <span class="button-fa-icon"> <i class="fa fa-bars slidepanel-open"></i> <i class="fa fa-times slidepanel-close"></i> </span> </button> </li> <li class="dropdown login-dropdown show-logged-in"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li><a href="/account/identities">Identities</a></li> <li><a href="/account/profile">Profile</a></li> <li><a href="/account/favorite/list">Favorites</a></li> <li> <a href="#" type="button" class="logout-button"> Logout </a> </li> </ul> </li> <li class="dropdown login-dropdown show-logged-out"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon avatar-placeholder" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li> <a href="/login/github"> <i class="fab fa-github fa-fw"></i> GitHub </a> </li> <li> <a href="/login/twitter"> <i class="fab fa-twitter fa-fw"></i> Twitter </a> </li> <li> <a href="/login/google"> <i class="fab fa-google fa-fw"></i> Google </a> </li> </ul> </li> <li class="dropdown login-dropdown hide-logged-in hide-logged-out"> <button> <i class="fa fa-user button-fa-icon" aria-hidden="true"></i> </button> </li> </ul> </nav> <div class="page-content "> <div id="perl-ad-target" class="top-notify-banner perl-ad-target"> </div> <nav class="sidebar"> <div class="slidepanel"> <ul class="nav-list "> <li class="nav-header no-margin-top"> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Scalar-List-Utils was released."> <span class="relatize">18 Oct 2024 11:30:40 UTC</span> </div> </li> <li> Distribution: <a href="/dist/Scalar-List-Utils">Scalar-List-Utils</a> </li> <li> Module version: 1.68 </li> <li> <a data-keyboard-shortcut="g s" href="/dist/Scalar-List-Utils/source/lib/List/Util.pm">Source</a> (<a href="/dist/Scalar-List-Utils/source/lib/List/Util.pm?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g b" href="/dist/Scalar-List-Utils/source/lib/List">Browse</a> (<a href="/dist/Scalar-List-Utils/source/lib/List?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g c" href="/dist/Scalar-List-Utils/changes">Changes</a> </li> <li> <a class="nopopup" href="/dist/Scalar-List-Utils/contribute">How to Contribute</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/Dual-Life/Scalar-List-Utils">Repository</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Scalar-List-Utils">Issues</a> (98) </li> <li> <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Scalar-List-Utils+1.68" title="Matrix">Testers</a> </li> <li> <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/PEVANS/Scalar-List-Utils-1.68">Kwalitee</a> </li> <li> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Scalar-List-Utils who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)"> Bus factor: 5 </div> </li> <li> License: perl_5 </li> <li> Perl: v5.6.0 </li> <li class="nav-header">Activity</li> <li> <div class="activity-graph"> <img src="/dist/Scalar-List-Utils/activity.svg?res=month" /> <div class="comment">24 month</div> </div> </li> <li class="nav-header">Tools</li> <li> <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/P/PE/PEVANS/Scalar-List-Utils-1.68.tar.gz"> Download (<span itemprop="fileSize">177.28KB</span>)</a> </li> <li> <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FPEVANS%2FScalar-List-Utils-1.68%2Flib%2FList%2FUtil.pm"> MetaCPAN Explorer </a> </li> <li> <a href="/dist/Scalar-List-Utils/permissions"> Permissions </a> </li> <li> <a href="/dist/Scalar-List-Utils/releases.rss"> Subscribe to distribution </a> </li> <li> <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog"> Install Instructions </button> </li> <li> <form action="/search"> <input type="hidden" name="q" value="dist:Scalar-List-Utils"> <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li> <form action="https://grep.metacpan.org/search"> <input type="hidden" name="qd" value="Scalar-List-Utils"> <input type="hidden" name="source" value="metacpan"> <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li class="version-jump"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Jump to version</option> <option disabled value="/release/PEVANS/Scalar-List-Utils-1.68/view/lib/List/Util.pm" >1.68 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.66/view/lib/List/Util.pm" >1.66 (PEVANS on 2024-09-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.65/view/lib/List/Util.pm" >1.65 (PEVANS on 2024-08-06)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.50_11/view/lib/List/Util.pm" >1.50_11 DEV (RURBAN on 2018-09-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.50_10/view/lib/List/Util.pm" >1.50_10 DEV (RURBAN on 2018-09-04)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_10/view/lib/List/Util.pm" >1.49_10 DEV (RURBAN on 2017-12-18)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_09/view/lib/List/Util.pm" >1.49_09 DEV (RURBAN on 2017-12-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_08/view/lib/List/Util.pm" >1.49_08 DEV (RURBAN on 2017-12-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.46_08/view/lib/List/Util.pm" >1.46_08 DEV (RURBAN on 2016-12-11)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_05/view/lib/List/Util.pm" >1.45_05 DEV (RURBAN on 2016-09-13)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_03/view/lib/List/Util.pm" >1.45_03 DEV (RURBAN on 2016-06-02)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_02/view/lib/List/Util.pm" >1.45_02 DEV (RURBAN on 2016-05-28)</option> <optgroup label="BackPAN">' <option value="/release/PEVANS/Scalar-List-Utils-1.67/view/lib/List/Util.pm" >1.67 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.64/view/lib/List/Util.pm" >1.64 (PEVANS on 2024-08-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.63/view/lib/List/Util.pm" >1.63 (PEVANS on 2022-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.62/view/lib/List/Util.pm" >1.62 (PEVANS on 2022-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.61/view/lib/List/Util.pm" >1.61 (PEVANS on 2022-02-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.60/view/lib/List/Util.pm" >1.60 (PEVANS on 2021-10-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.59/view/lib/List/Util.pm" >1.59 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.58/view/lib/List/Util.pm" >1.58 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.57/view/lib/List/Util.pm" >1.57 (PEVANS on 2021-09-11)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.56/view/lib/List/Util.pm" >1.56 (PEVANS on 2021-03-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.55/view/lib/List/Util.pm" >1.55 (PEVANS on 2020-04-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.55-TRIAL/view/lib/List/Util.pm" >1.55-TRIAL DEV (PEVANS on 2020-04-09)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.54/view/lib/List/Util.pm" >1.54 (PEVANS on 2020-02-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.53/view/lib/List/Util.pm" >1.53 (PEVANS on 2019-10-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.52_001/view/lib/List/Util.pm" >1.52_001 DEV (PEVANS on 2019-10-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.52/view/lib/List/Util.pm" >1.52 (PEVANS on 2019-08-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.51/view/lib/List/Util.pm" >1.51 (PEVANS on 2019-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.50/view/lib/List/Util.pm" >1.50 (PEVANS on 2018-02-20)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.49/view/lib/List/Util.pm" >1.49 (PEVANS on 2017-09-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.48/view/lib/List/Util.pm" >1.48 (PEVANS on 2017-06-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.47/view/lib/List/Util.pm" >1.47 (PEVANS on 2016-12-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.46/view/lib/List/Util.pm" >1.46 (PEVANS on 2016-09-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.45/view/lib/List/Util.pm" >1.45 (PEVANS on 2016-03-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44_002/view/lib/List/Util.pm" >1.44_002 DEV (PEVANS on 2016-03-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44_001/view/lib/List/Util.pm" >1.44_001 DEV (PEVANS on 2016-03-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44/view/lib/List/Util.pm" >1.44 (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_005/view/lib/List/Util.pm" >1.43_005 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_004/view/lib/List/Util.pm" >1.43_004 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_003/view/lib/List/Util.pm" >1.43_003 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_002/view/lib/List/Util.pm" >1.43_002 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_001/view/lib/List/Util.pm" >1.43_001 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43/view/lib/List/Util.pm" >1.43 (PEVANS on 2016-02-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42_002/view/lib/List/Util.pm" >1.42_002 DEV (PEVANS on 2016-02-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42_001/view/lib/List/Util.pm" >1.42_001 DEV (PEVANS on 2016-02-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42/view/lib/List/Util.pm" >1.42 (PEVANS on 2015-04-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.41/view/lib/List/Util.pm" >1.41 (PEVANS on 2014-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.40/view/lib/List/Util.pm" >1.40 (PEVANS on 2014-08-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_004/view/lib/List/Util.pm" >1.39_004 DEV (PEVANS on 2014-08-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_003/view/lib/List/Util.pm" >1.39_003 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_002/view/lib/List/Util.pm" >1.39_002 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_001/view/lib/List/Util.pm" >1.39_001 DEV (PEVANS on 2014-08-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39/view/lib/List/Util.pm" >1.39 (PEVANS on 2014-06-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.38/view/lib/List/Util.pm" >1.38 (PEVANS on 2014-01-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.37/view/lib/List/Util.pm" >1.37 (PEVANS on 2014-01-21)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.36/view/lib/List/Util.pm" >1.36 (PEVANS on 2014-01-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.35/view/lib/List/Util.pm" >1.35 (PEVANS on 2013-10-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.34/view/lib/List/Util.pm" >1.34 (PEVANS on 2013-10-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.33/view/lib/List/Util.pm" >1.33 (PEVANS on 2013-10-13)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.32/view/lib/List/Util.pm" >1.32 (PEVANS on 2013-08-31)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.31/view/lib/List/Util.pm" >1.31 (PEVANS on 2013-08-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.30/view/lib/List/Util.pm" >1.30 (PEVANS on 2013-08-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.29_001/view/lib/List/Util.pm" >1.29_001 DEV (PEVANS on 2013-08-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.29/view/lib/List/Util.pm" >1.29 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.28/view/lib/List/Util.pm" >1.28 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27_002/view/lib/List/Util.pm" >1.27_002 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27_001/view/lib/List/Util.pm" >1.27_001 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27/view/lib/List/Util.pm" >1.27 (PEVANS on 2012-12-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.26_001/view/lib/List/Util.pm" >1.26_001 DEV (PEVANS on 2012-12-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.26/view/lib/List/Util.pm" >1.26 (PEVANS on 2012-12-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.25/view/lib/List/Util.pm" >1.25 (PEVANS on 2012-03-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.24/view/lib/List/Util.pm" >1.24 (PEVANS on 2012-03-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.23_04/view/lib/List/Util.pm" >1.23_04 DEV (PEVANS on 2012-03-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_03/view/lib/List/Util.pm" >1.23_03 DEV (GBARR on 2010-09-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_02/view/lib/List/Util.pm" >1.23_02 DEV (GBARR on 2010-03-30)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_01/view/lib/List/Util.pm" >1.23_01 DEV (GBARR on 2010-03-22)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23/view/lib/List/Util.pm" >1.23 (GBARR on 2010-03-11)</option> <option value="/release/GBARR/Scalar-List-Utils-1.22/view/lib/List/Util.pm" >1.22 (GBARR on 2009-11-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.21/view/lib/List/Util.pm" >1.21 (GBARR on 2009-05-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.20/view/lib/List/Util.pm" >1.20 (GBARR on 2009-05-13)</option> <option value="/release/GBARR/Scalar-List-Utils-1.19/view/lib/List/Util.pm" >1.19 (GBARR on 2006-12-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.18/view/lib/List/Util.pm" >1.18 (GBARR on 2005-11-25)</option> <option value="/release/GBARR/Scalar-List-Utils-1.17/view/lib/List/Util.pm" >1.17 (GBARR on 2005-05-23)</option> <option value="/release/GBARR/Scalar-List-Utils-1.16/view/lib/List/Util.pm" >1.16 (GBARR on 2005-05-20)</option> <option value="/release/GBARR/Scalar-List-Utils-1.14/view/lib/List/Util.pm" >1.14 (GBARR on 2004-05-22)</option> <option value="/release/GBARR/Scalar-List-Utils-1.13/view/lib/List/Util.pm" >1.13 (GBARR on 2003-09-25)</option> <option value="/release/GBARR/Scalar-List-Utils-1.12/view/lib/List/Util.pm" >1.12 (GBARR on 2003-08-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.11/view/lib/List/Util.pm" >1.11 (GBARR on 2003-02-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.10/view/lib/List/Util.pm" >1.10 (GBARR on 2003-02-04)</option> <option value="/release/GBARR/Scalar-List-Utils-1.09/view/lib/List/Util.pm" >1.09 (GBARR on 2002-12-12)</option> <option value="/release/GBARR/Scalar-List-Utils-1.08/view/lib/List/Util.pm" >1.08 (GBARR on 2002-11-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.0701/view/lib/List/Util.pm" >1.0701 (GBARR on 2002-04-29)</option> <option value="/release/GBARR/Scalar-List-Utils-1.07/view/lib/List/Util.pm" >1.07 (GBARR on 2002-03-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.06/view/lib/List/Util.pm" >1.06 (GBARR on 2001-09-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.05/view/lib/List/Util.pm" >1.05 (GBARR on 2001-09-05)</option> <option value="/release/GBARR/Scalar-List-Utils-1.04/view/lib/List/Util.pm" >1.04 (GBARR on 2001-09-05)</option> <option value="/release/GBARR/Scalar-List-Utils-1.03/view/lib/List/Util.pm" >1.03 (GBARR on 2001-09-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.02/view/lib/List/Util.pm" >1.02 (GBARR on 2000-04-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.01/view/lib/List/Util.pm" >1.01 (GBARR on 2000-03-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.00/view/lib/List/Util.pm" >1.00 (GBARR on 1999-07-16)</option> <option value="/release/GBARR/Scalar-List-Utils-0.10/view/lib/List/Util.pm" >0.10 (GBARR on 1999-06-01)</option> </optgroup> </select> </li> <li class="version-diff"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Diff with version</option> <option disabled value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.68/lib/List/Util.pm" >1.68 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.66/lib/List/Util.pm" >1.66 (PEVANS on 2024-09-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.65/lib/List/Util.pm" >1.65 (PEVANS on 2024-08-06)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.50_11/lib/List/Util.pm" >1.50_11 DEV (RURBAN on 2018-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.50_10/lib/List/Util.pm" >1.50_10 DEV (RURBAN on 2018-09-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.49_10/lib/List/Util.pm" >1.49_10 DEV (RURBAN on 2017-12-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.49_09/lib/List/Util.pm" >1.49_09 DEV (RURBAN on 2017-12-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.49_08/lib/List/Util.pm" >1.49_08 DEV (RURBAN on 2017-12-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.46_08/lib/List/Util.pm" >1.46_08 DEV (RURBAN on 2016-12-11)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.45_05/lib/List/Util.pm" >1.45_05 DEV (RURBAN on 2016-09-13)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.45_03/lib/List/Util.pm" >1.45_03 DEV (RURBAN on 2016-06-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/RURBAN/Scalar-List-Utils-1.45_02/lib/List/Util.pm" >1.45_02 DEV (RURBAN on 2016-05-28)</option> <optgroup label="BackPAN">' <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.67/lib/List/Util.pm" >1.67 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.64/lib/List/Util.pm" >1.64 (PEVANS on 2024-08-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.63/lib/List/Util.pm" >1.63 (PEVANS on 2022-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.62/lib/List/Util.pm" >1.62 (PEVANS on 2022-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.61/lib/List/Util.pm" >1.61 (PEVANS on 2022-02-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.60/lib/List/Util.pm" >1.60 (PEVANS on 2021-10-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.59/lib/List/Util.pm" >1.59 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.58/lib/List/Util.pm" >1.58 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.57/lib/List/Util.pm" >1.57 (PEVANS on 2021-09-11)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.56/lib/List/Util.pm" >1.56 (PEVANS on 2021-03-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.55/lib/List/Util.pm" >1.55 (PEVANS on 2020-04-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.55-TRIAL/lib/List/Util.pm" >1.55-TRIAL DEV (PEVANS on 2020-04-09)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.54/lib/List/Util.pm" >1.54 (PEVANS on 2020-02-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.53/lib/List/Util.pm" >1.53 (PEVANS on 2019-10-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.52_001/lib/List/Util.pm" >1.52_001 DEV (PEVANS on 2019-10-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.52/lib/List/Util.pm" >1.52 (PEVANS on 2019-08-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.51/lib/List/Util.pm" >1.51 (PEVANS on 2019-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.50/lib/List/Util.pm" >1.50 (PEVANS on 2018-02-20)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.49/lib/List/Util.pm" >1.49 (PEVANS on 2017-09-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.48/lib/List/Util.pm" >1.48 (PEVANS on 2017-06-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.47/lib/List/Util.pm" >1.47 (PEVANS on 2016-12-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.46/lib/List/Util.pm" >1.46 (PEVANS on 2016-09-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.45/lib/List/Util.pm" >1.45 (PEVANS on 2016-03-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.44_002/lib/List/Util.pm" >1.44_002 DEV (PEVANS on 2016-03-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.44_001/lib/List/Util.pm" >1.44_001 DEV (PEVANS on 2016-03-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.44/lib/List/Util.pm" >1.44 (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43_005/lib/List/Util.pm" >1.43_005 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43_004/lib/List/Util.pm" >1.43_004 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43_003/lib/List/Util.pm" >1.43_003 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43_002/lib/List/Util.pm" >1.43_002 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43_001/lib/List/Util.pm" >1.43_001 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.43/lib/List/Util.pm" >1.43 (PEVANS on 2016-02-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.42_002/lib/List/Util.pm" >1.42_002 DEV (PEVANS on 2016-02-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.42_001/lib/List/Util.pm" >1.42_001 DEV (PEVANS on 2016-02-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.42/lib/List/Util.pm" >1.42 (PEVANS on 2015-04-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.41/lib/List/Util.pm" >1.41 (PEVANS on 2014-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.40/lib/List/Util.pm" >1.40 (PEVANS on 2014-08-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.39_004/lib/List/Util.pm" >1.39_004 DEV (PEVANS on 2014-08-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.39_003/lib/List/Util.pm" >1.39_003 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.39_002/lib/List/Util.pm" >1.39_002 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.39_001/lib/List/Util.pm" >1.39_001 DEV (PEVANS on 2014-08-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.39/lib/List/Util.pm" >1.39 (PEVANS on 2014-06-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.38/lib/List/Util.pm" >1.38 (PEVANS on 2014-01-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.37/lib/List/Util.pm" >1.37 (PEVANS on 2014-01-21)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.36/lib/List/Util.pm" >1.36 (PEVANS on 2014-01-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.35/lib/List/Util.pm" >1.35 (PEVANS on 2013-10-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.34/lib/List/Util.pm" >1.34 (PEVANS on 2013-10-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.33/lib/List/Util.pm" >1.33 (PEVANS on 2013-10-13)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.32/lib/List/Util.pm" >1.32 (PEVANS on 2013-08-31)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.31/lib/List/Util.pm" >1.31 (PEVANS on 2013-08-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.30/lib/List/Util.pm" >1.30 (PEVANS on 2013-08-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.29_001/lib/List/Util.pm" >1.29_001 DEV (PEVANS on 2013-08-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.29/lib/List/Util.pm" >1.29 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.28/lib/List/Util.pm" >1.28 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.27_002/lib/List/Util.pm" >1.27_002 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.27_001/lib/List/Util.pm" >1.27_001 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.27/lib/List/Util.pm" >1.27 (PEVANS on 2012-12-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.26_001/lib/List/Util.pm" >1.26_001 DEV (PEVANS on 2012-12-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.26/lib/List/Util.pm" >1.26 (PEVANS on 2012-12-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.25/lib/List/Util.pm" >1.25 (PEVANS on 2012-03-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.24/lib/List/Util.pm" >1.24 (PEVANS on 2012-03-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/PEVANS/Scalar-List-Utils-1.23_04/lib/List/Util.pm" >1.23_04 DEV (PEVANS on 2012-03-10)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.23_03/lib/List/Util.pm" >1.23_03 DEV (GBARR on 2010-09-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.23_02/lib/List/Util.pm" >1.23_02 DEV (GBARR on 2010-03-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.23_01/lib/List/Util.pm" >1.23_01 DEV (GBARR on 2010-03-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.23/lib/List/Util.pm" >1.23 (GBARR on 2010-03-11)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.22/lib/List/Util.pm" >1.22 (GBARR on 2009-11-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.21/lib/List/Util.pm" >1.21 (GBARR on 2009-05-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.20/lib/List/Util.pm" >1.20 (GBARR on 2009-05-13)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.19/lib/List/Util.pm" >1.19 (GBARR on 2006-12-10)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.18/lib/List/Util.pm" >1.18 (GBARR on 2005-11-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.17/lib/List/Util.pm" >1.17 (GBARR on 2005-05-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.16/lib/List/Util.pm" >1.16 (GBARR on 2005-05-20)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.14/lib/List/Util.pm" >1.14 (GBARR on 2004-05-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.13/lib/List/Util.pm" >1.13 (GBARR on 2003-09-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.12/lib/List/Util.pm" >1.12 (GBARR on 2003-08-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.11/lib/List/Util.pm" >1.11 (GBARR on 2003-02-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.10/lib/List/Util.pm" >1.10 (GBARR on 2003-02-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.09/lib/List/Util.pm" >1.09 (GBARR on 2002-12-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.08/lib/List/Util.pm" >1.08 (GBARR on 2002-11-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.0701/lib/List/Util.pm" >1.0701 (GBARR on 2002-04-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.07/lib/List/Util.pm" >1.07 (GBARR on 2002-03-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.06/lib/List/Util.pm" >1.06 (GBARR on 2001-09-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.05/lib/List/Util.pm" >1.05 (GBARR on 2001-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.04/lib/List/Util.pm" >1.04 (GBARR on 2001-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.03/lib/List/Util.pm" >1.03 (GBARR on 2001-09-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.02/lib/List/Util.pm" >1.02 (GBARR on 2000-04-10)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.01/lib/List/Util.pm" >1.01 (GBARR on 2000-03-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-1.00/lib/List/Util.pm" >1.00 (GBARR on 1999-07-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.68/diff/GBARR/Scalar-List-Utils-0.10/lib/List/Util.pm" >0.10 (GBARR on 1999-06-01)</option> </optgroup> </select> </li> <li> <ul class="dependencies"> <li class="nav-header">Dependencies</li> <li><i>none</i></li> <li> <hr> </li> <li> <a href="/module/List::Util/requires">Reverse dependencies</a> </li> <li> <a href="http://deps.cpantesters.org/?module=List%3A%3AUtil">CPAN Testers List</a> </li> <li> <a href="https://cpandeps.grinnz.com/?dist=Scalar-List-Utils">Dependency graph</a> </li> </ul> </li> <li class="nav-header">Permalinks</li> <li> <a href="/release/PEVANS/Scalar-List-Utils-1.68/view/lib/List/Util.pm">This version</a> </li> <li> <a href="/pod/List::Util">Latest version</a> </li> <li> <div class="plussers"> <div class="nav-header">++ed by:</div> <div> <a class="display-all" href="/author/DOY"><img src="https://www.gravatar.com/avatar/88766de7a058697d3d0335b8d384fd2a?d=identicon&amp;s=20" title="DOY" alt="DOY"></a> <a class="display-all" href="/author/HANENKAMP"><img src="https://www.gravatar.com/avatar/e5b51c69496e22e3e2d037604cc6d8c9?d=identicon&amp;s=20" title="HANENKAMP" alt="HANENKAMP"></a> <a class="display-all" href="/author/RRWO"><img src="https://www.gravatar.com/avatar/4a5274bc5d690ee3d619f044778771a7?d=identicon&amp;s=20" title="RRWO" alt="RRWO"></a> <a class="display-all" href="/author/SOMMREY"><img src="https://www.gravatar.com/avatar/23981fc366a289f29d5167a3b09c469f?d=identicon&amp;s=20" title="SOMMREY" alt="SOMMREY"></a> <a class="display-all" href="/author/UFOBAT"><img src="https://www.gravatar.com/avatar/e3e69782e3e7ce4f08849411cc189554?d=identicon&amp;s=20" title="UFOBAT" alt="UFOBAT"></a> </div> <!-- Display counts of plussers--> <div> <a href="/dist/Scalar-List-Utils/plussers">101 PAUSE users</a> </div> <div> 78 non-PAUSE users </div> </div> </li> <li> <div> <button class="contributors-show-button btn-link">and 1 contributors</button> <div id="metacpan_contributors" class="slide-out slide-out-hidden"> <div> <ul> <li class="contributor" data-cpan-author="GBARR" data-contrib-email="gbarr@cpan.org" > <a href="/author/GBARR" class="cpan-author"> <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/91e0a99c0201988cad4e53833c8aa2b5?d=identicon&amp;s=20" /> Graham Barr </a> </li> </ul> </div> </div> </div> </li> </ul> </div> </nav> <div class="content-navigation"> <div class="breadcrumbs"> <span> <a data-keyboard-shortcut="g a" rel="author" href="/author/PEVANS" class="author-name">Paul Evans</a> </span> <span>&nbsp;/&nbsp;</span> <div class="release dist-release status-latest maturity-released"> <span class="dropdown"><b class="caret"></b></span> <select class="select-navigator "> <option selected value="/release/PEVANS/Scalar-List-Utils-1.68/view/lib/List/Util.pm" >1.68 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.66/view/lib/List/Util.pm" >1.66 (PEVANS on 2024-09-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.65/view/lib/List/Util.pm" >1.65 (PEVANS on 2024-08-06)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.50_11/view/lib/List/Util.pm" >1.50_11 DEV (RURBAN on 2018-09-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.50_10/view/lib/List/Util.pm" >1.50_10 DEV (RURBAN on 2018-09-04)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_10/view/lib/List/Util.pm" >1.49_10 DEV (RURBAN on 2017-12-18)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_09/view/lib/List/Util.pm" >1.49_09 DEV (RURBAN on 2017-12-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.49_08/view/lib/List/Util.pm" >1.49_08 DEV (RURBAN on 2017-12-05)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.46_08/view/lib/List/Util.pm" >1.46_08 DEV (RURBAN on 2016-12-11)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_05/view/lib/List/Util.pm" >1.45_05 DEV (RURBAN on 2016-09-13)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_03/view/lib/List/Util.pm" >1.45_03 DEV (RURBAN on 2016-06-02)</option> <option value="/release/RURBAN/Scalar-List-Utils-1.45_02/view/lib/List/Util.pm" >1.45_02 DEV (RURBAN on 2016-05-28)</option> <optgroup label="BackPAN">' <option value="/release/PEVANS/Scalar-List-Utils-1.67/view/lib/List/Util.pm" >1.67 (PEVANS on 2024-10-18)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.64/view/lib/List/Util.pm" >1.64 (PEVANS on 2024-08-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.63/view/lib/List/Util.pm" >1.63 (PEVANS on 2022-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.62/view/lib/List/Util.pm" >1.62 (PEVANS on 2022-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.61/view/lib/List/Util.pm" >1.61 (PEVANS on 2022-02-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.60/view/lib/List/Util.pm" >1.60 (PEVANS on 2021-10-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.59/view/lib/List/Util.pm" >1.59 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.58/view/lib/List/Util.pm" >1.58 (PEVANS on 2021-09-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.57/view/lib/List/Util.pm" >1.57 (PEVANS on 2021-09-11)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.56/view/lib/List/Util.pm" >1.56 (PEVANS on 2021-03-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.55/view/lib/List/Util.pm" >1.55 (PEVANS on 2020-04-12)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.55-TRIAL/view/lib/List/Util.pm" >1.55-TRIAL DEV (PEVANS on 2020-04-09)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.54/view/lib/List/Util.pm" >1.54 (PEVANS on 2020-02-02)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.53/view/lib/List/Util.pm" >1.53 (PEVANS on 2019-10-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.52_001/view/lib/List/Util.pm" >1.52_001 DEV (PEVANS on 2019-10-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.52/view/lib/List/Util.pm" >1.52 (PEVANS on 2019-08-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.51/view/lib/List/Util.pm" >1.51 (PEVANS on 2019-08-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.50/view/lib/List/Util.pm" >1.50 (PEVANS on 2018-02-20)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.49/view/lib/List/Util.pm" >1.49 (PEVANS on 2017-09-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.48/view/lib/List/Util.pm" >1.48 (PEVANS on 2017-06-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.47/view/lib/List/Util.pm" >1.47 (PEVANS on 2016-12-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.46/view/lib/List/Util.pm" >1.46 (PEVANS on 2016-09-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.45/view/lib/List/Util.pm" >1.45 (PEVANS on 2016-03-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44_002/view/lib/List/Util.pm" >1.44_002 DEV (PEVANS on 2016-03-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44_001/view/lib/List/Util.pm" >1.44_001 DEV (PEVANS on 2016-03-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.44/view/lib/List/Util.pm" >1.44 (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_005/view/lib/List/Util.pm" >1.43_005 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_004/view/lib/List/Util.pm" >1.43_004 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_003/view/lib/List/Util.pm" >1.43_003 DEV (PEVANS on 2016-03-17)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_002/view/lib/List/Util.pm" >1.43_002 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43_001/view/lib/List/Util.pm" >1.43_001 DEV (PEVANS on 2016-03-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.43/view/lib/List/Util.pm" >1.43 (PEVANS on 2016-02-08)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42_002/view/lib/List/Util.pm" >1.42_002 DEV (PEVANS on 2016-02-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42_001/view/lib/List/Util.pm" >1.42_001 DEV (PEVANS on 2016-02-03)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.42/view/lib/List/Util.pm" >1.42 (PEVANS on 2015-04-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.41/view/lib/List/Util.pm" >1.41 (PEVANS on 2014-09-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.40/view/lib/List/Util.pm" >1.40 (PEVANS on 2014-08-30)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_004/view/lib/List/Util.pm" >1.39_004 DEV (PEVANS on 2014-08-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_003/view/lib/List/Util.pm" >1.39_003 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_002/view/lib/List/Util.pm" >1.39_002 DEV (PEVANS on 2014-08-26)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39_001/view/lib/List/Util.pm" >1.39_001 DEV (PEVANS on 2014-08-25)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.39/view/lib/List/Util.pm" >1.39 (PEVANS on 2014-06-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.38/view/lib/List/Util.pm" >1.38 (PEVANS on 2014-01-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.37/view/lib/List/Util.pm" >1.37 (PEVANS on 2014-01-21)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.36/view/lib/List/Util.pm" >1.36 (PEVANS on 2014-01-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.35/view/lib/List/Util.pm" >1.35 (PEVANS on 2013-10-19)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.34/view/lib/List/Util.pm" >1.34 (PEVANS on 2013-10-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.33/view/lib/List/Util.pm" >1.33 (PEVANS on 2013-10-13)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.32/view/lib/List/Util.pm" >1.32 (PEVANS on 2013-08-31)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.31/view/lib/List/Util.pm" >1.31 (PEVANS on 2013-08-14)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.30/view/lib/List/Util.pm" >1.30 (PEVANS on 2013-08-05)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.29_001/view/lib/List/Util.pm" >1.29_001 DEV (PEVANS on 2013-08-04)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.29/view/lib/List/Util.pm" >1.29 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.28/view/lib/List/Util.pm" >1.28 (PEVANS on 2013-08-01)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27_002/view/lib/List/Util.pm" >1.27_002 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27_001/view/lib/List/Util.pm" >1.27_001 DEV (PEVANS on 2013-07-29)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.27/view/lib/List/Util.pm" >1.27 (PEVANS on 2012-12-27)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.26_001/view/lib/List/Util.pm" >1.26_001 DEV (PEVANS on 2012-12-23)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.26/view/lib/List/Util.pm" >1.26 (PEVANS on 2012-12-16)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.25/view/lib/List/Util.pm" >1.25 (PEVANS on 2012-03-24)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.24/view/lib/List/Util.pm" >1.24 (PEVANS on 2012-03-22)</option> <option value="/release/PEVANS/Scalar-List-Utils-1.23_04/view/lib/List/Util.pm" >1.23_04 DEV (PEVANS on 2012-03-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_03/view/lib/List/Util.pm" >1.23_03 DEV (GBARR on 2010-09-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_02/view/lib/List/Util.pm" >1.23_02 DEV (GBARR on 2010-03-30)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23_01/view/lib/List/Util.pm" >1.23_01 DEV (GBARR on 2010-03-22)</option> <option value="/release/GBARR/Scalar-List-Utils-1.23/view/lib/List/Util.pm" >1.23 (GBARR on 2010-03-11)</option> <option value="/release/GBARR/Scalar-List-Utils-1.22/view/lib/List/Util.pm" >1.22 (GBARR on 2009-11-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.21/view/lib/List/Util.pm" >1.21 (GBARR on 2009-05-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.20/view/lib/List/Util.pm" >1.20 (GBARR on 2009-05-13)</option> <option value="/release/GBARR/Scalar-List-Utils-1.19/view/lib/List/Util.pm" >1.19 (GBARR on 2006-12-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.18/view/lib/List/Util.pm" >1.18 (GBARR on 2005-11-25)</option> <option value="/release/GBARR/Scalar-List-Utils-1.17/view/lib/List/Util.pm" >1.17 (GBARR on 2005-05-23)</option> <option value="/release/GBARR/Scalar-List-Utils-1.16/view/lib/List/Util.pm" >1.16 (GBARR on 2005-05-20)</option> <option value="/release/GBARR/Scalar-List-Utils-1.14/view/lib/List/Util.pm" >1.14 (GBARR on 2004-05-22)</option> <option value="/release/GBARR/Scalar-List-Utils-1.13/view/lib/List/Util.pm" >1.13 (GBARR on 2003-09-25)</option> <option value="/release/GBARR/Scalar-List-Utils-1.12/view/lib/List/Util.pm" >1.12 (GBARR on 2003-08-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.11/view/lib/List/Util.pm" >1.11 (GBARR on 2003-02-14)</option> <option value="/release/GBARR/Scalar-List-Utils-1.10/view/lib/List/Util.pm" >1.10 (GBARR on 2003-02-04)</option> <option value="/release/GBARR/Scalar-List-Utils-1.09/view/lib/List/Util.pm" >1.09 (GBARR on 2002-12-12)</option> <option value="/release/GBARR/Scalar-List-Utils-1.08/view/lib/List/Util.pm" >1.08 (GBARR on 2002-11-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.0701/view/lib/List/Util.pm" >1.0701 (GBARR on 2002-04-29)</option> <option value="/release/GBARR/Scalar-List-Utils-1.07/view/lib/List/Util.pm" >1.07 (GBARR on 2002-03-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.06/view/lib/List/Util.pm" >1.06 (GBARR on 2001-09-18)</option> <option value="/release/GBARR/Scalar-List-Utils-1.05/view/lib/List/Util.pm" >1.05 (GBARR on 2001-09-05)</option> <option value="/release/GBARR/Scalar-List-Utils-1.04/view/lib/List/Util.pm" >1.04 (GBARR on 2001-09-05)</option> <option value="/release/GBARR/Scalar-List-Utils-1.03/view/lib/List/Util.pm" >1.03 (GBARR on 2001-09-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.02/view/lib/List/Util.pm" >1.02 (GBARR on 2000-04-10)</option> <option value="/release/GBARR/Scalar-List-Utils-1.01/view/lib/List/Util.pm" >1.01 (GBARR on 2000-03-03)</option> <option value="/release/GBARR/Scalar-List-Utils-1.00/view/lib/List/Util.pm" >1.00 (GBARR on 1999-07-16)</option> <option value="/release/GBARR/Scalar-List-Utils-0.10/view/lib/List/Util.pm" >0.10 (GBARR on 1999-06-01)</option> </optgroup> </select> <a data-keyboard-shortcut="g d" class="release-name" href="/dist/Scalar-List-Utils">Scalar-List-Utils-1.68</a> </div> <span class="river-gauge-gauge"> <svg width="24px" height="15px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <title> River stage five &#10; • 4117 direct dependents &#10; • 33320 total dependents </title> <rect x="0" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="5" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="10" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="15" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="20" y="0" width="4" height="15" fill="#7ea3f2" /> </g> </svg> </span> <div id="Scalar-List-Utils-fav" class="show-logged-in"> <form action="/account/favorite/add" style="display: inline" method="POST"> <input type="hidden" name="remove" value="0"> <input type="hidden" name="release" value="Scalar-List-Utils-1.68"> <input type="hidden" name="author" value="PEVANS"> <input type="hidden" name="distribution" value="Scalar-List-Utils"> <button type="submit" class="favorite highlight"><span>179</span> ++</button> </form> </div> <div class="show-logged-out"> <button class="fav-not-logged-in favorite highlight"><span>179</span> ++</button> </div> / <span>List::Util</span> </div> </div> <main class="content"> <nav class="toc"> <div class="toc-header"><strong>Contents</strong></div> <ul> <li><a href="#NAME">NAME</a></li> <li><a href="#SYNOPSIS">SYNOPSIS</a></li> <li><a href="#DESCRIPTION">DESCRIPTION</a></li> <li><a href="#LIST-REDUCTION-FUNCTIONS">LIST-REDUCTION FUNCTIONS</a> <ul> <li><a href="#reduce">reduce</a></li> <li><a href="#reductions">reductions</a></li> <li><a href="#any">any</a></li> <li><a href="#all">all</a></li> <li><a href="#none">none</a></li> <li><a href="#notall">notall</a></li> <li><a href="#first">first</a></li> <li><a href="#max">max</a></li> <li><a href="#maxstr">maxstr</a></li> <li><a href="#min">min</a></li> <li><a href="#minstr">minstr</a></li> <li><a href="#product">product</a></li> <li><a href="#sum">sum</a></li> <li><a href="#sum0">sum0</a></li> </ul> </li> <li><a href="#KEY%2FVALUE-PAIR-LIST-FUNCTIONS">KEY/VALUE PAIR LIST FUNCTIONS</a> <ul> <li><a href="#pairs">pairs</a></li> <li><a href="#unpairs">unpairs</a></li> <li><a href="#pairkeys">pairkeys</a></li> <li><a href="#pairvalues">pairvalues</a></li> <li><a href="#pairgrep">pairgrep</a></li> <li><a href="#pairfirst">pairfirst</a></li> <li><a href="#pairmap">pairmap</a></li> </ul> </li> <li><a href="#OTHER-FUNCTIONS">OTHER FUNCTIONS</a> <ul> <li><a href="#shuffle">shuffle</a></li> <li><a href="#sample">sample</a></li> <li><a href="#uniq">uniq</a></li> <li><a href="#uniqint">uniqint</a></li> <li><a href="#uniqnum">uniqnum</a></li> <li><a href="#uniqstr">uniqstr</a></li> <li><a href="#head">head</a></li> <li><a href="#tail">tail</a></li> <li><a href="#zip">zip</a></li> <li><a href="#mesh">mesh</a></li> </ul> </li> <li><a href="#CONFIGURATION-VARIABLES">CONFIGURATION VARIABLES</a> <ul> <li><a href="#%24RAND">$RAND</a></li> </ul> </li> <li><a href="#KNOWN-BUGS">KNOWN BUGS</a> <ul> <li><a href="#RT-%2395409">RT #95409</a></li> <li><a href="#uniqnum()-on-oversized-bignums">uniqnum() on oversized bignums</a></li> </ul> </li> <li><a href="#SUGGESTED-ADDITIONS">SUGGESTED ADDITIONS</a></li> <li><a href="#SEE-ALSO">SEE ALSO</a></li> <li><a href="#COPYRIGHT">COPYRIGHT</a></li> </ul></nav> <div class="pod anchors"> <h1 id="NAME">NAME</h1> <p>List::Util - A selection of general-utility list subroutines</p> <h1 id="SYNOPSIS">SYNOPSIS</h1> <pre><code>use List::Util qw( reduce any all none notall first reductions max maxstr min minstr product sum sum0 pairs unpairs pairkeys pairvalues pairfirst pairgrep pairmap shuffle uniq uniqint uniqnum uniqstr head tail zip mesh );</code></pre> <h1 id="DESCRIPTION">DESCRIPTION</h1> <p><code>List::Util</code> contains a selection of subroutines that people have expressed would be nice to have in the perl core, but the usage would not really be high enough to warrant the use of a keyword, and the size so small such that being individual extensions would be wasteful.</p> <p>By default <code>List::Util</code> does not export any subroutines.</p> <h1 id="LIST-REDUCTION-FUNCTIONS"><a id="LIST"></a>LIST-REDUCTION FUNCTIONS</h1> <p>The following set of functions all apply a given block of code to a list of values.</p> <h2 id="reduce">reduce</h2> <pre><code>$result = reduce { BLOCK } @list</code></pre> <p>Reduces <code>@list</code> by calling <code>BLOCK</code> in a scalar context multiple times, setting <code>$a</code> and <code>$b</code> each time. The first call will be with <code>$a</code> and <code>$b</code> set to the first two elements of the list, subsequent calls will be done by setting <code>$a</code> to the result of the previous call and <code>$b</code> to the next element in the list.</p> <p>Returns the result of the last call to the <code>BLOCK</code>. If <code>@list</code> is empty then <code>undef</code> is returned. If <code>@list</code> only contains one element then that element is returned and <code>BLOCK</code> is not executed.</p> <p>The following examples all demonstrate how <code>reduce</code> could be used to implement the other list-reduction functions in this module. (They are not in fact implemented like this, but instead in a more efficient manner in individual C functions).</p> <pre><code>$foo = reduce { defined($a) ? $a : $code-&gt;(local $_ = $b) ? $b : undef } undef, @list # first $foo = reduce { $a &gt; $b ? $a : $b } 1..10 # max $foo = reduce { $a gt $b ? $a : $b } &#39;A&#39;..&#39;Z&#39; # maxstr $foo = reduce { $a &lt; $b ? $a : $b } 1..10 # min $foo = reduce { $a lt $b ? $a : $b } &#39;aa&#39;..&#39;zz&#39; # minstr $foo = reduce { $a + $b } 1 .. 10 # sum $foo = reduce { $a . $b } @bar # concat $foo = reduce { $a || $code-&gt;(local $_ = $b) } 0, @bar # any $foo = reduce { $a &amp;&amp; $code-&gt;(local $_ = $b) } 1, @bar # all $foo = reduce { $a &amp;&amp; !$code-&gt;(local $_ = $b) } 1, @bar # none $foo = reduce { $a || !$code-&gt;(local $_ = $b) } 0, @bar # notall # Note that these implementations do not fully short-circuit</code></pre> <p>If your algorithm requires that <code>reduce</code> produce an identity value, then make sure that you always pass that identity value as the first argument to prevent <code>undef</code> being returned</p> <pre><code>$foo = reduce { $a + $b } 0, @values; # sum with 0 identity value</code></pre> <p>The above example code blocks also suggest how to use <code>reduce</code> to build a more efficient combined version of one of these basic functions and a <code>map</code> block. For example, to find the total length of all the strings in a list, we could use</p> <pre><code>$total = sum map { length } @strings;</code></pre> <p>However, this produces a list of temporary integer values as long as the original list of strings, only to reduce it down to a single value again. We can compute the same result more efficiently by using <code>reduce</code> with a code block that accumulates lengths by writing this instead as:</p> <pre><code>$total = reduce { $a + length $b } 0, @strings</code></pre> <p>The other scalar-returning list reduction functions are all specialisations of this generic idea.</p> <h2 id="reductions">reductions</h2> <pre><code>@results = reductions { BLOCK } @list</code></pre> <p><i>Since version 1.54.</i></p> <p>Similar to <code>reduce</code> except that it also returns the intermediate values along with the final result. As before, <code>$a</code> is set to the first element of the given list, and the <code>BLOCK</code> is then called once for remaining item in the list set into <code>$b</code>, with the result being captured for return as well as becoming the new value for <code>$a</code>.</p> <p>The returned list will begin with the initial value for <code>$a</code>, followed by each return value from the block in order. The final value of the result will be identical to what the <code>reduce</code> function would have returned given the same block and list.</p> <pre><code>reduce { &quot;$a-$b&quot; } &quot;a&quot;..&quot;d&quot; # &quot;a-b-c-d&quot; reductions { &quot;$a-$b&quot; } &quot;a&quot;..&quot;d&quot; # &quot;a&quot;, &quot;a-b&quot;, &quot;a-b-c&quot;, &quot;a-b-c-d&quot;</code></pre> <h2 id="any">any</h2> <pre><code>my $bool = any { BLOCK } @list;</code></pre> <p><i>Since version 1.33.</i></p> <p>Similar to <code>grep</code> in that it evaluates <code>BLOCK</code> setting <code>$_</code> to each element of <code>@list</code> in turn. <code>any</code> returns true if any element makes the <code>BLOCK</code> return a true value. If <code>BLOCK</code> never returns true or <code>@list</code> was empty then it returns false.</p> <p>Many cases of using <code>grep</code> in a conditional can be written using <code>any</code> instead, as it can short-circuit after the first true result.</p> <pre><code>if( any { length &gt; 10 } @strings ) { # at least one string has more than 10 characters }</code></pre> <p>Note: Due to XS issues the block passed may be able to access the outer @_ directly. This is not intentional and will break under debugger.</p> <h2 id="all">all</h2> <pre><code>my $bool = all { BLOCK } @list;</code></pre> <p><i>Since version 1.33.</i></p> <p>Similar to <a href="#any">&quot;any&quot;</a>, except that it requires all elements of the <code>@list</code> to make the <code>BLOCK</code> return true. If any element returns false, then it returns false. If the <code>BLOCK</code> never returns false or the <code>@list</code> was empty then it returns true.</p> <p>Note: Due to XS issues the block passed may be able to access the outer @_ directly. This is not intentional and will break under debugger.</p> <h2 id="none">none</h2> <h2 id="notall">notall</h2> <pre><code>my $bool = none { BLOCK } @list; my $bool = notall { BLOCK } @list;</code></pre> <p><i>Since version 1.33.</i></p> <p>Similar to <a href="#any">&quot;any&quot;</a> and <a href="#all">&quot;all&quot;</a>, but with the return sense inverted. <code>none</code> returns true only if no value in the <code>@list</code> causes the <code>BLOCK</code> to return true, and <code>notall</code> returns true only if not all of the values do.</p> <p>Note: Due to XS issues the block passed may be able to access the outer @_ directly. This is not intentional and will break under debugger.</p> <h2 id="first">first</h2> <pre><code>my $val = first { BLOCK } @list;</code></pre> <p>Similar to <code>grep</code> in that it evaluates <code>BLOCK</code> setting <code>$_</code> to each element of <code>@list</code> in turn. <code>first</code> returns the first element where the result from <code>BLOCK</code> is a true value. If <code>BLOCK</code> never returns true or <code>@list</code> was empty then <code>undef</code> is returned.</p> <pre><code>$foo = first { defined($_) } @list # first defined value in @list $foo = first { $_ &gt; $value } @list # first value in @list which # is greater than $value</code></pre> <h2 id="max">max</h2> <pre><code>my $num = max @list;</code></pre> <p>Returns the entry in the list with the highest numerical value. If the list is empty then <code>undef</code> is returned.</p> <pre><code>$foo = max 1..10 # 10 $foo = max 3,9,12 # 12 $foo = max @bar, @baz # whatever</code></pre> <h2 id="maxstr">maxstr</h2> <pre><code>my $str = maxstr @list;</code></pre> <p>Similar to <a href="#max">&quot;max&quot;</a>, but treats all the entries in the list as strings and returns the highest string as defined by the <code>gt</code> operator. If the list is empty then <code>undef</code> is returned.</p> <pre><code>$foo = maxstr &#39;A&#39;..&#39;Z&#39; # &#39;Z&#39; $foo = maxstr &quot;hello&quot;,&quot;world&quot; # &quot;world&quot; $foo = maxstr @bar, @baz # whatever</code></pre> <h2 id="min">min</h2> <pre><code>my $num = min @list;</code></pre> <p>Similar to <a href="#max">&quot;max&quot;</a> but returns the entry in the list with the lowest numerical value. If the list is empty then <code>undef</code> is returned.</p> <pre><code>$foo = min 1..10 # 1 $foo = min 3,9,12 # 3 $foo = min @bar, @baz # whatever</code></pre> <h2 id="minstr">minstr</h2> <pre><code>my $str = minstr @list;</code></pre> <p>Similar to <a href="#min">&quot;min&quot;</a>, but treats all the entries in the list as strings and returns the lowest string as defined by the <code>lt</code> operator. If the list is empty then <code>undef</code> is returned.</p> <pre><code>$foo = minstr &#39;A&#39;..&#39;Z&#39; # &#39;A&#39; $foo = minstr &quot;hello&quot;,&quot;world&quot; # &quot;hello&quot; $foo = minstr @bar, @baz # whatever</code></pre> <h2 id="product">product</h2> <pre><code>my $num = product @list;</code></pre> <p><i>Since version 1.35.</i></p> <p>Returns the numerical product of all the elements in <code>@list</code>. If <code>@list</code> is empty then <code>1</code> is returned.</p> <pre><code>$foo = product 1..10 # 3628800 $foo = product 3,9,12 # 324</code></pre> <h2 id="sum">sum</h2> <pre><code>my $num_or_undef = sum @list;</code></pre> <p>Returns the numerical sum of all the elements in <code>@list</code>. For backwards compatibility, if <code>@list</code> is empty then <code>undef</code> is returned.</p> <pre><code>$foo = sum 1..10 # 55 $foo = sum 3,9,12 # 24 $foo = sum @bar, @baz # whatever</code></pre> <h2 id="sum0">sum0</h2> <pre><code>my $num = sum0 @list;</code></pre> <p><i>Since version 1.26.</i></p> <p>Similar to <a href="#sum">&quot;sum&quot;</a>, except this returns 0 when given an empty list, rather than <code>undef</code>.</p> <h1 id="KEY/VALUE-PAIR-LIST-FUNCTIONS"><a id="KEY"></a><a id="KEY-VALUE-PAIR-LIST-FUNCTIONS"></a>KEY/VALUE PAIR LIST FUNCTIONS</h1> <p>The following set of functions, all inspired by <a href="/pod/List::Pairwise">List::Pairwise</a>, consume an even-sized list of pairs. The pairs may be key/value associations from a hash, or just a list of values. The functions will all preserve the original ordering of the pairs, and will not be confused by multiple pairs having the same &quot;key&quot; value - nor even do they require that the first of each pair be a plain string.</p> <p><b>NOTE</b>: At the time of writing, the following <code>pair*</code> functions that take a block do not modify the value of <code>$_</code> within the block, and instead operate using the <code>$a</code> and <code>$b</code> globals instead. This has turned out to be a poor design, as it precludes the ability to provide a <code>pairsort</code> function. Better would be to pass pair-like objects as 2-element array references in <code>$_</code>, in a style similar to the return value of the <code>pairs</code> function. At some future version this behaviour may be added.</p> <p>Until then, users are alerted <b>NOT</b> to rely on the value of <code>$_</code> remaining unmodified between the outside and the inside of the control block. In particular, the following example is <b>UNSAFE</b>:</p> <pre><code>my @kvlist = ... foreach (qw( some keys here )) { my @items = pairgrep { $a eq $_ } @kvlist; ... }</code></pre> <p>Instead, write this using a lexical variable:</p> <pre><code>foreach my $key (qw( some keys here )) { my @items = pairgrep { $a eq $key } @kvlist; ... }</code></pre> <h2 id="pairs">pairs</h2> <pre><code>my @pairs = pairs @kvlist;</code></pre> <p><i>Since version 1.29.</i></p> <p>A convenient shortcut to operating on even-sized lists of pairs, this function returns a list of <code>ARRAY</code> references, each containing two items from the given list. It is a more efficient version of</p> <pre><code>@pairs = pairmap { [ $a, $b ] } @kvlist</code></pre> <p>It is most convenient to use in a <code>foreach</code> loop, for example:</p> <pre><code>foreach my $pair ( pairs @kvlist ) { my ( $key, $value ) = @$pair; ... }</code></pre> <p>Since version <code>1.39</code> these <code>ARRAY</code> references are blessed objects, recognising the two methods <code>key</code> and <code>value</code>. The following code is equivalent:</p> <pre><code>foreach my $pair ( pairs @kvlist ) { my $key = $pair-&gt;key; my $value = $pair-&gt;value; ... }</code></pre> <p>Since version <code>1.51</code> they also have a <code>TO_JSON</code> method to ease serialisation.</p> <h2 id="unpairs">unpairs</h2> <pre><code>my @kvlist = unpairs @pairs</code></pre> <p><i>Since version 1.42.</i></p> <p>The inverse function to <code>pairs</code>; this function takes a list of <code>ARRAY</code> references containing two elements each, and returns a flattened list of the two values from each of the pairs, in order. This is notionally equivalent to</p> <pre><code>my @kvlist = map { @{$_}[0,1] } @pairs</code></pre> <p>except that it is implemented more efficiently internally. Specifically, for any input item it will extract exactly two values for the output list; using <code>undef</code> if the input array references are short.</p> <p>Between <code>pairs</code> and <code>unpairs</code>, a higher-order list function can be used to operate on the pairs as single scalars; such as the following near-equivalents of the other <code>pair*</code> higher-order functions:</p> <pre><code>@kvlist = unpairs grep { FUNC } pairs @kvlist # Like pairgrep, but takes $_ instead of $a and $b @kvlist = unpairs map { FUNC } pairs @kvlist # Like pairmap, but takes $_ instead of $a and $b</code></pre> <p>Note however that these versions will not behave as nicely in scalar context.</p> <p>Finally, this technique can be used to implement a sort on a keyvalue pair list; e.g.:</p> <pre><code>@kvlist = unpairs sort { $a-&gt;key cmp $b-&gt;key } pairs @kvlist</code></pre> <h2 id="pairkeys">pairkeys</h2> <pre><code>my @keys = pairkeys @kvlist;</code></pre> <p><i>Since version 1.29.</i></p> <p>A convenient shortcut to operating on even-sized lists of pairs, this function returns a list of the first values of each of the pairs in the given list. It is a more efficient version of</p> <pre><code>@keys = pairmap { $a } @kvlist</code></pre> <h2 id="pairvalues">pairvalues</h2> <pre><code>my @values = pairvalues @kvlist;</code></pre> <p><i>Since version 1.29.</i></p> <p>A convenient shortcut to operating on even-sized lists of pairs, this function returns a list of the second values of each of the pairs in the given list. It is a more efficient version of</p> <pre><code>@values = pairmap { $b } @kvlist</code></pre> <h2 id="pairgrep">pairgrep</h2> <pre><code>my @kvlist = pairgrep { BLOCK } @kvlist; my $count = pairgrep { BLOCK } @kvlist;</code></pre> <p><i>Since version 1.29.</i></p> <p>Similar to perl&#39;s <code>grep</code> keyword, but interprets the given list as an even-sized list of pairs. It invokes the <code>BLOCK</code> multiple times, in scalar context, with <code>$a</code> and <code>$b</code> set to successive pairs of values from the <code>@kvlist</code>.</p> <p>Returns an even-sized list of those pairs for which the <code>BLOCK</code> returned true in list context, or the count of the <b>number of pairs</b> in scalar context. (Note, therefore, in scalar context that it returns a number half the size of the count of items it would have returned in list context).</p> <pre><code>@subset = pairgrep { $a =~ m/^[[:upper:]]+$/ } @kvlist</code></pre> <p>As with <code>grep</code> aliasing <code>$_</code> to list elements, <code>pairgrep</code> aliases <code>$a</code> and <code>$b</code> to elements of the given list. Any modifications of it by the code block will be visible to the caller.</p> <h2 id="pairfirst">pairfirst</h2> <pre><code>my ( $key, $val ) = pairfirst { BLOCK } @kvlist; my $found = pairfirst { BLOCK } @kvlist;</code></pre> <p><i>Since version 1.30.</i></p> <p>Similar to the <a href="#first">&quot;first&quot;</a> function, but interprets the given list as an even-sized list of pairs. It invokes the <code>BLOCK</code> multiple times, in scalar context, with <code>$a</code> and <code>$b</code> set to successive pairs of values from the <code>@kvlist</code>.</p> <p>Returns the first pair of values from the list for which the <code>BLOCK</code> returned true in list context, or an empty list of no such pair was found. In scalar context it returns a simple boolean value, rather than either the key or the value found.</p> <pre><code>( $key, $value ) = pairfirst { $a =~ m/^[[:upper:]]+$/ } @kvlist</code></pre> <p>As with <code>grep</code> aliasing <code>$_</code> to list elements, <code>pairfirst</code> aliases <code>$a</code> and <code>$b</code> to elements of the given list. Any modifications of it by the code block will be visible to the caller.</p> <h2 id="pairmap">pairmap</h2> <pre><code>my @list = pairmap { BLOCK } @kvlist; my $count = pairmap { BLOCK } @kvlist;</code></pre> <p><i>Since version 1.29.</i></p> <p>Similar to perl&#39;s <code>map</code> keyword, but interprets the given list as an even-sized list of pairs. It invokes the <code>BLOCK</code> multiple times, in list context, with <code>$a</code> and <code>$b</code> set to successive pairs of values from the <code>@kvlist</code>.</p> <p>Returns the concatenation of all the values returned by the <code>BLOCK</code> in list context, or the count of the number of items that would have been returned in scalar context.</p> <pre><code>@result = pairmap { &quot;The key $a has value $b&quot; } @kvlist</code></pre> <p>As with <code>map</code> aliasing <code>$_</code> to list elements, <code>pairmap</code> aliases <code>$a</code> and <code>$b</code> to elements of the given list. Any modifications of it by the code block will be visible to the caller.</p> <p>See <a href="#KNOWN-BUGS">&quot;KNOWN BUGS&quot;</a> for a known-bug with <code>pairmap</code>, and a workaround.</p> <h1 id="OTHER-FUNCTIONS"><a id="OTHER"></a>OTHER FUNCTIONS</h1> <h2 id="shuffle">shuffle</h2> <pre><code>my @values = shuffle @values;</code></pre> <p>Returns the values of the input in a random order</p> <pre><code>@cards = shuffle 0..51 # 0..51 in a random order</code></pre> <p>This function is affected by the <code>$RAND</code> variable.</p> <h2 id="sample">sample</h2> <pre><code>my @items = sample $count, @values</code></pre> <p><i>Since version 1.54.</i></p> <p>Randomly select the given number of elements from the input list. Any given position in the input list will be selected at most once.</p> <p>If there are fewer than <code>$count</code> items in the list then the function will return once all of them have been randomly selected; effectively the function behaves similarly to <a href="#shuffle">&quot;shuffle&quot;</a>.</p> <p>This function is affected by the <code>$RAND</code> variable.</p> <h2 id="uniq">uniq</h2> <pre><code>my @subset = uniq @values</code></pre> <p><i>Since version 1.45.</i></p> <p>Filters a list of values to remove subsequent duplicates, as judged by a DWIM-ish string equality or <code>undef</code> test. Preserves the order of unique elements, and retains the first value of any duplicate set.</p> <pre><code>my $count = uniq @values</code></pre> <p>In scalar context, returns the number of elements that would have been returned as a list.</p> <p>The <code>undef</code> value is treated by this function as distinct from the empty string, and no warning will be produced. It is left as-is in the returned list. Subsequent <code>undef</code> values are still considered identical to the first, and will be removed.</p> <h2 id="uniqint">uniqint</h2> <pre><code>my @subset = uniqint @values</code></pre> <p><i>Since version 1.55.</i></p> <p>Filters a list of values to remove subsequent duplicates, as judged by an integer numerical equality test. Preserves the order of unique elements, and retains the first value of any duplicate set. Values in the returned list will be coerced into integers.</p> <pre><code>my $count = uniqint @values</code></pre> <p>In scalar context, returns the number of elements that would have been returned as a list.</p> <p>Note that <code>undef</code> is treated much as other numerical operations treat it; it compares equal to zero but additionally produces a warning if such warnings are enabled (<code>use warnings &#39;uninitialized&#39;;</code>). In addition, an <code>undef</code> in the returned list is coerced into a numerical zero, so that the entire list of values returned by <code>uniqint</code> are well-behaved as integers.</p> <h2 id="uniqnum">uniqnum</h2> <pre><code>my @subset = uniqnum @values</code></pre> <p><i>Since version 1.44.</i></p> <p>Filters a list of values to remove subsequent duplicates, as judged by a numerical equality test. Preserves the order of unique elements, and retains the first value of any duplicate set.</p> <pre><code>my $count = uniqnum @values</code></pre> <p>In scalar context, returns the number of elements that would have been returned as a list.</p> <p>Note that <code>undef</code> is treated much as other numerical operations treat it; it compares equal to zero but additionally produces a warning if such warnings are enabled (<code>use warnings &#39;uninitialized&#39;;</code>). In addition, an <code>undef</code> in the returned list is coerced into a numerical zero, so that the entire list of values returned by <code>uniqnum</code> are well-behaved as numbers.</p> <p>Note also that multiple IEEE <code>NaN</code> values are treated as duplicates of each other, regardless of any differences in their payloads, and despite the fact that <code>0+&#39;NaN&#39; == 0+&#39;NaN&#39;</code> yields false.</p> <h2 id="uniqstr">uniqstr</h2> <pre><code>my @subset = uniqstr @values</code></pre> <p><i>Since version 1.45.</i></p> <p>Filters a list of values to remove subsequent duplicates, as judged by a string equality test. Preserves the order of unique elements, and retains the first value of any duplicate set.</p> <pre><code>my $count = uniqstr @values</code></pre> <p>In scalar context, returns the number of elements that would have been returned as a list.</p> <p>Note that <code>undef</code> is treated much as other string operations treat it; it compares equal to the empty string but additionally produces a warning if such warnings are enabled (<code>use warnings &#39;uninitialized&#39;;</code>). In addition, an <code>undef</code> in the returned list is coerced into an empty string, so that the entire list of values returned by <code>uniqstr</code> are well-behaved as strings.</p> <h2 id="head">head</h2> <pre><code>my @values = head $size, @list;</code></pre> <p><i>Since version 1.50.</i></p> <p>Returns the first <code>$size</code> elements from <code>@list</code>. If <code>$size</code> is negative, returns all but the last <code>$size</code> elements from <code>@list</code>.</p> <pre><code>@result = head 2, qw( foo bar baz ); # foo, bar @result = head -2, qw( foo bar baz ); # foo</code></pre> <h2 id="tail">tail</h2> <pre><code>my @values = tail $size, @list;</code></pre> <p><i>Since version 1.50.</i></p> <p>Returns the last <code>$size</code> elements from <code>@list</code>. If <code>$size</code> is negative, returns all but the first <code>$size</code> elements from <code>@list</code>.</p> <pre><code>@result = tail 2, qw( foo bar baz ); # bar, baz @result = tail -2, qw( foo bar baz ); # baz</code></pre> <h2 id="zip">zip</h2> <pre><code>my @result = zip [1..3], [&#39;a&#39;..&#39;c&#39;]; # [1, &#39;a&#39;], [2, &#39;b&#39;], [3, &#39;c&#39;]</code></pre> <p><i>Since version 1.56.</i></p> <p>Returns a list of array references, composed of elements from the given list of array references. Each array in the returned list is composed of elements at that corresponding position from each of the given input arrays. If any input arrays run out of elements before others, then <code>undef</code> will be inserted into the result to fill in the gaps.</p> <p>The <code>zip</code> function is particularly handy for iterating over multiple arrays at the same time with a <code>foreach</code> loop, taking one element from each:</p> <pre><code>foreach ( zip \@xs, \@ys, \@zs ) { my ($x, $y, $z) = @$_; ... }</code></pre> <p><b>NOTE</b> to users of <a href="/pod/List::MoreUtils">List::MoreUtils</a>: This function does not behave the same as <code>List::MoreUtils::zip</code>, but is actually a non-prototyped equivalent to <code>List::MoreUtils::zip_unflatten</code>. This function does not apply a prototype, so make sure to invoke it with references to arrays.</p> <p>For a function similar to the <code>zip</code> function from <code>List::MoreUtils</code>, see <a href="/pod/mesh">mesh</a>.</p> <pre><code>my @result = zip_shortest ...</code></pre> <p>A variation of the function that differs in how it behaves when given input arrays of differing lengths. <code>zip_shortest</code> will stop as soon as any one of the input arrays run out of elements, discarding any remaining unused values from the others.</p> <pre><code>my @result = zip_longest ...</code></pre> <p><code>zip_longest</code> is an alias to the <code>zip</code> function, provided simply to be explicit about that behaviour as compared to <code>zip_shortest</code>.</p> <h2 id="mesh">mesh</h2> <pre><code>my @result = mesh [1..3], [&#39;a&#39;..&#39;c&#39;]; # (1, &#39;a&#39;, 2, &#39;b&#39;, 3, &#39;c&#39;)</code></pre> <p><i>Since version 1.56.</i></p> <p>Returns a list of items collected from elements of the given list of array references. Each section of items in the returned list is composed of elements at the corresponding position from each of the given input arrays. If any input arrays run out of elements before others, then <code>undef</code> will be inserted into the result to fill in the gaps.</p> <p>This is similar to <a href="/pod/zip">zip</a>, except that all of the ranges in the result are returned in one long flattened list, instead of being bundled into separate arrays.</p> <p>Because it returns a flat list of items, the <code>mesh</code> function is particularly useful for building a hash out of two separate arrays of keys and values:</p> <pre><code>my %hash = mesh \@keys, \@values; my $href = { mesh \@keys, \@values };</code></pre> <p><b>NOTE</b> to users of <a href="/pod/List::MoreUtils">List::MoreUtils</a>: This function is a non-prototyped equivalent to <code>List::MoreUtils::mesh</code> or <code>List::MoreUtils::zip</code> (themselves aliases of each other). This function does not apply a prototype, so make sure to invoke it with references to arrays.</p> <pre><code>my @result = mesh_shortest ... my @result = mesh_longest ...</code></pre> <p>These variations are similar to those of <a href="/pod/zip">zip</a>, in that they differ in behaviour when one of the input lists runs out of elements before the others.</p> <h1 id="CONFIGURATION-VARIABLES"><a id="CONFIGURATION"></a>CONFIGURATION VARIABLES</h1> <h2 id="$RAND"><a id="RAND"></a>$RAND</h2> <pre><code>local $List::Util::RAND = sub { ... };</code></pre> <p><i>Since version 1.54.</i></p> <p>This package variable is used by code which needs to generate random numbers (such as the <a href="#shuffle">&quot;shuffle&quot;</a> and <a href="#sample">&quot;sample&quot;</a> functions). If set to a CODE reference it provides an alternative to perl&#39;s builtin <code>rand()</code> function. When a new random number is needed this function will be invoked with no arguments and is expected to return a floating-point value, of which only the fractional part will be used.</p> <h1 id="KNOWN-BUGS"><a id="KNOWN"></a>KNOWN BUGS</h1> <h2 id="RT-#95409"><a id="RT"></a><a id="RT-95409"></a>RT #95409</h2> <p><a href="https://rt.cpan.org/Ticket/Display.html?id=95409">https://rt.cpan.org/Ticket/Display.html?id=95409</a></p> <p>If the block of code given to <a href="#pairmap">&quot;pairmap&quot;</a> contains lexical variables that are captured by a returned closure, and the closure is executed after the block has been re-used for the next iteration, these lexicals will not see the correct values. For example:</p> <pre><code>my @subs = pairmap { my $var = &quot;$a is $b&quot;; sub { print &quot;$var\n&quot; }; } one =&gt; 1, two =&gt; 2, three =&gt; 3; $_-&gt;() for @subs;</code></pre> <p>Will incorrectly print</p> <pre><code>three is 3 three is 3 three is 3</code></pre> <p>This is due to the performance optimisation of using <code>MULTICALL</code> for the code block, which means that fresh SVs do not get allocated for each call to the block. Instead, the same SV is re-assigned for each iteration, and all the closures will share the value seen on the final iteration.</p> <p>To work around this bug, surround the code with a second set of braces. This creates an inner block that defeats the <code>MULTICALL</code> logic, and does get fresh SVs allocated each time:</p> <pre><code>my @subs = pairmap { { my $var = &quot;$a is $b&quot;; sub { print &quot;$var\n&quot;; } } } one =&gt; 1, two =&gt; 2, three =&gt; 3;</code></pre> <p>This bug only affects closures that are generated by the block but used afterwards. Lexical variables that are only used during the lifetime of the block&#39;s execution will take their individual values for each invocation, as normal.</p> <h2 id="uniqnum()-on-oversized-bignums"><a id="uniqnum1"></a><a id="uniqnum-on-oversized-bignums"></a>uniqnum() on oversized bignums</h2> <p>Due to the way that <code>uniqnum()</code> compares numbers, it cannot distinguish differences between bignums (especially bigints) that are too large to fit in the native platform types. For example,</p> <pre><code>my $x = Math::BigInt-&gt;new( &quot;1&quot; x 100 ); my $y = $x + 1; say for uniqnum( $x, $y );</code></pre> <p>Will print just the value of <code>$x</code>, believing that <code>$y</code> is a numerically- equivalent value. This bug does not affect <code>uniqstr()</code>, which will correctly observe that the two values stringify to different strings.</p> <h1 id="SUGGESTED-ADDITIONS"><a id="SUGGESTED"></a>SUGGESTED ADDITIONS</h1> <p>The following are additions that have been requested, but I have been reluctant to add due to them being very simple to implement in perl</p> <pre><code># How many elements are true sub true { scalar grep { $_ } @_ } # How many elements are false sub false { scalar grep { !$_ } @_ }</code></pre> <h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1> <p><a href="/pod/Scalar::Util">Scalar::Util</a>, <a href="/pod/List::MoreUtils">List::MoreUtils</a></p> <h1 id="COPYRIGHT">COPYRIGHT</h1> <p>Copyright (c) 1997-2007 Graham Barr &lt;gbarr@pobox.com&gt;. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p> <p>Recent additions and current maintenance by Paul Evans, &lt;leonerd@leonerd.org.uk&gt;.</p></div> <div id="metacpan_install-instructions-dialog" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">Module Install Instructions</h4> </div> <div class="modal-body"> <p>To install Scalar::List::Utils, copy and paste the appropriate command in to your terminal.</p> <p><a href="/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p> <pre><code>cpanm Scalar::List::Utils</code></pre> <p><a href="/pod/CPAN">CPAN shell</a></p> <pre><code>perl -MCPAN -e shell install Scalar::List::Utils</code></pre> <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p> </div> <div class="modal-footer"> <a href="#" data-dismiss="modal" class="btn">Close</a> </div> </div> </div> </div> </main> <div class="content-pagination"> </div> </div> <footer class="footer"> <div class="footer-container"> <div class="footer-social"> <div class="footer-link footer-logo"> <a href="/"> <img src="/static/images/metacpan-logo.svg" alt="MetaCPAN" /> </a> </div> <a class="footer-social-link" href="https://github.com/metacpan"> <i class="fab fa-github-square"></i> </a> <a class="footer-social-link" href="https://fosstodon.org/@metacpan"> <i class="fab fa-mastodon"></i> </a> </div> <div class="footer-links"> <div class="footer-link"> <a href="/about">About</a> </div> <div class="footer-link"> <a href="/about/sponsors">Sponsor</a> </div> <div class="footer-link"> <a href="https://grep.metacpan.org">grep::cpan</a> </div> <div class="footer-link"> <a href="/recent">Recent</a> </div> <div class="footer-link"> <a href="/about/faq">FAQ</a> </div> <div class="footer-link"> <a href="/tools">Tools</a> </div> <div class="footer-link"> <a href="https://fastapi.metacpan.org/">API</a> </div> <div class="footer-link"> <a href="https://www.perl.org/">Perl.org</a> </div> </div> <div class="footer-sponsors"> <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener"> <img class="footer-sponsor-bytemark" src="/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener"> <img class="footer-sponsor-liquidweb" src="/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener"> <img class="footer-sponsor-deriv" src="/static/images/sponsors/deriv.svg" alt="Deriv logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener"> <img class="footer-sponsor-geocode" src="/static/images/sponsors/geocodelogo.svg" alt="Geocode logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener"> <img class="footer-sponsor-fastly" src="/static/images/sponsors/fastly_logo.svg" alt="Fastly logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener"> <img class="footer-sponsor-opencage" src="/static/images/sponsors/open-cage.svg" alt="OpenCage logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://www.elastic.co/" rel="noopener"> <img class="footer-sponsor-elastic" src="/static/images/sponsors/elastic.svg" alt="Elastic logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://route4me.com/" rel="noopener"> <img class="footer-sponsor-route4me" src="/static/images/sponsors/route4me.png" alt="Route4Me logo"> </a> </div> </div> </footer> <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Keyboard Shortcuts</h4> </div> <div class="modal-body row"> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Global</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>s</kbd> </td> <td>Focus search bar</td> </tr> <tr> <td class="keys"> <kbd>?</kbd> </td> <td>Bring up this help dialog</td> </tr> </tbody> </table> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>GitHub</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>p</kbd> </td> <td>Go to pull requests</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>go to github issues (only if github is preferred repository)</td> </tr> </tbody> </table> </div> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>POD</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>a</kbd> </td> <td>Go to author</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>c</kbd> </td> <td>Go to changes</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>Go to issues</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>d</kbd> </td> <td>Go to dist</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>r</kbd> </td> <td>Go to repository/SCM</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>s</kbd> </td> <td>Go to source</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>b</kbd> </td> <td>Go to file browse</td> </tr> </tbody> </table> </div> <div class="col-md-12"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Search terms</th> </tr> </thead> <tbody> <tr> <td><em>module:</em> (e.g. <a href="/search?q=module%3APlugin">module:Plugin</a>)</td> </tr> <tr> <td><em>distribution:</em> (e.g. <a href="/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td> </tr> <tr> <td><em>author:</em> (e.g. <a href="/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td> </tr> <tr> <td><em>version:</em> (e.g. <a href="/search?q=version%3A1.00">version:1.00</a>)</td> </tr> </tbody> </table> </div> </div> <div class="modal-footer"></div> </div> </div> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10