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.
Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.