From 0df0b335daa8da306f5395f0d0cecc0bcb6943fa Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Fri, 21 Sep 2018 11:38:15 +0200
Subject: [PATCH] Bug 20023: (QA follow-up) Tiny simplification
Content-Type: text/plain; charset=utf-8

Remove empty emails from the list rightaway (incl. all spaces).
Would be tempted to lc the params->{email} at the start btw..

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 opac/opac-password-recovery.pl | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl
index 4c28b0f..8a26147 100755
--- a/opac/opac-password-recovery.pl
+++ b/opac/opac-password-recovery.pl
@@ -73,13 +73,9 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
         $errMultipleAccountsForEmail = 1;
     }
     elsif ( $borrower = $search_results->next() ) {    # One matching borrower
-        my @emails = ( $borrower->email || '', $borrower->emailpro || '', $borrower->B_email || '');
+        my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email );
 
-        my $firstNonEmptyEmail = '';
-        foreach my $address ( @emails ) {
-            $firstNonEmptyEmail = $address if length $address;
-            last if $firstNonEmptyEmail;
-        }
+        my $firstNonEmptyEmail = shift @emails;
 
         # Is the given email one of the borrower's ?
         if ( $email && !( grep /^$email$/i, @emails ) ) {
-- 
2.1.4