7 require Config; import Config;
8 keys %Config; # Silence warning
9 if ($Config{extensions} !~ /\bList\/Util\b/) {
10 print "1..0 # Skip: List::Util was not built\n";
16 use List::Util qw(first);
20 print "not " unless defined &first;
23 print "not " unless 9 == first { 8 == ($_ - 1) } 9,4,5,6;
26 print "not " if defined(first { 0 } 1,2,3,4);
29 print "not " if defined(first { 0 });
32 my $foo = first { $_->[1] le "e" and "e" le $_->[2] }
33 [qw(a b c)], [qw(d e f)], [qw(g h i)];
34 print "not " unless $foo->[0] eq 'd';
37 # Check that eval{} inside the block works correctly
39 print "not " unless 5 == first { eval { die }; ($i == 5, $i = $_)[0] } 0,1,2,3,4,5,5;
42 print "not " if defined eval { first { die if $_ } 0,0,1 };
46 $x = '' unless defined $x;
49 sub foobar { first { !defined(wantarray) || wantarray } "not ","not ","not " }