From f3f8cde34fc9ae7eb3289b07f752e1e8ef7cc734 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 1 Aug 2024 09:18:46 +0000 Subject: [PATCH] Address improvements: Remove trialing and leading white space Remove existing commas before replacing \r\n --- Koha/Plugin/Com/PTFSEurope/HLISD.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/Plugin/Com/PTFSEurope/HLISD.pm b/Koha/Plugin/Com/PTFSEurope/HLISD.pm index ed6ff03..5eaa432 100644 --- a/Koha/Plugin/Com/PTFSEurope/HLISD.pm +++ b/Koha/Plugin/Com/PTFSEurope/HLISD.pm @@ -181,10 +181,13 @@ sub harvest_libraries { next; } - # Replace '\r\n' with ', ' my $address = $library->{attributes}->{ $self->get_HLISD_library_field('branchaddress1') }; + $address =~ s/,//g; + my @address_split = split( /\r\n/, $address ); - my $final_address = join( ', ', @address_split ); + my @address_lines = map { $_ =~ s/^\s+|\s+$//gr } @address_split; + + my $final_address = join( ', ', @address_lines ); $self->debug_msg( sprintf( "Importing %s", $library->{id} ) ); my $library = Koha::Library->new(