diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl index 4c28b0feb9..8a2614730c 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 ) ) {