tqisjim has asked for the wisdom of the Perl Monks concerning the following question:
I'm a little confused by the man page for List::MoreUtils::first_value(). I've concluded that it's functionally identical to List::Util::first(). Can anyone please confirm?
I'm looking for the equivalent of the following:
## first example $result = first { defined $_ } map { foobar( $_ ) } @list ; ## second example foreach ( @list ) { last if defined( $result = foobar( $_ ) ) ; }
In the first example, foobar is called on every list element, and first()'s economic magic is only applied to the defined operator. The second example demonstrates precisely the functionality I'm looking for.
Specifically, is there any list operator in any module that solves this problem? Otherwise, has anyone else encountered this missing functionality?
Quite sincerely- Jim
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List::MoreUtils::first_value() question
by BrowserUk (Patriarch) on Jul 30, 2013 at 15:15 UTC | |
|
Re: List::MoreUtils::first_value() question
by tobyink (Canon) on Jul 30, 2013 at 15:19 UTC | |
by tqisjim (Beadle) on Jul 30, 2013 at 16:33 UTC | |
by davido (Cardinal) on Jul 30, 2013 at 19:05 UTC |