Skip to content

Commit

Permalink
simplify by using List::Util::any
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Feb 24, 2024
1 parent 16a4f86 commit 62fd8a1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/Biodiverse/Indices.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use warnings;
#use Data::Dumper;
use Scalar::Util qw /blessed weaken/;
use List::MoreUtils qw /uniq/;
use List::Util qw /sum/;
use List::Util qw /sum any/;
use English ( -no_match_vars );
use Ref::Util qw { :all };
use JSON::MaybeXS;
Expand Down Expand Up @@ -795,15 +795,9 @@ sub parse_dependencies_for_calc {

foreach my $required_arg ( sort @$reqd_args_a ) {
my $re = qr /^($required_arg)$/;
my $is_defined;
CALC_ARG:
foreach
my $calc_arg ( sort grep { $_ =~ $re } keys %$calc_args ) {
if ( defined $calc_args->{$calc_arg} ) {
$is_defined++;
last CALC_ARG;
}
}
my $is_defined
= any { $_ =~ $re && defined $calc_args->{$_}}
sort keys %$calc_args;

if ( !$is_defined ) {
Biodiverse::Indices::MissingRequiredArguments->throw(
Expand Down

0 comments on commit 62fd8a1

Please sign in to comment.