From 6388ffd7025290b1ca3e4c9b7a1ae67dfb63ed72 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 1 Apr 2019 18:46:21 +0100 Subject: [PATCH] Bug 21890: (QA follow-up) Use List::Util::any When possible it's a good idea to use `any` from List::Util to shortcut on the first occurence of a truthy value. Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- Koha/Template/Plugin/Categories.pm | 3 ++- opac/opac-password-recovery.pl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm index f12c660faf..140f12a395 100644 --- a/Koha/Template/Plugin/Categories.pm +++ b/Koha/Template/Plugin/Categories.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Template::Plugin; use base qw( Template::Plugin ); +use List::Util qw(any); use Koha::Patron::Categories; sub all { @@ -34,7 +35,7 @@ sub GetName { } sub can_any_reset_password { - return ( grep { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } ) + return ( any { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } ) ? 1 : 0; } diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl index 8563e2551e..5cc6bd36f3 100755 --- a/opac/opac-password-recovery.pl +++ b/opac/opac-password-recovery.pl @@ -14,6 +14,7 @@ use Koha::Patrons; my $query = new CGI; use HTML::Entities; use Try::Tiny; +use List::Util qw/any/; my ( $template, $dummy, $cookie ) = get_template_and_user( { @@ -84,7 +85,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { $firstNonEmptyEmail = $emails[0] if @emails; # Is the given email one of the borrower's ? - if ( $email && !( grep /^$email$/i, @emails ) ) { + if ( $email && !( any { /^$email$/i } @emails ) ) { $hasError = 1; $errNoBorrowerFound = 1; } -- 2.39.5