Try the
first() function List::Util. Its like grep but returns as soon as it finds the first match.
% perldoc List::Util
first BLOCK LIST
Similar to "grep" in that it evaluates BLOCK setting $_ to
+each
element of LIST in turn. "first" returns the first element
+where
the result from BLOCK is a true value. If BLOCK never retur
+ns true
or LIST was empty then "undef" is returned.
$foo = first { defined($_) } @list # first defined v
+alue in @list
$foo = first { $_ > $value } @list # first value in
+@list which
# is greater than
+ $value