Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Standard Modules > 8.140. List::Util

List::Util

A collection of list-related subroutines. As of Perl 5.8, List::Util is included with the Perl source kit.

You can get the first item of a list (that matches the condition in BLOCK) like so:

#!/usr/local/bin/perl -w
use List::Util qw(first);

my @ll = qw(one two three);

my $fir = first { defined($_) } @ll;
print "$fir\n"; # Prints 'one'

List::Util implements (but does not export) the following methods.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint