ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / serials / lateissues-export.pl
index cc23ddc..e36e734 100755 (executable)
@@ -46,14 +46,19 @@ my $csv = Text::CSV_XS->new({
 my $content = $csv_profile->content;
 my ( @headers, @fields );
 while ( $content =~ /
-    ([^=]+) # header
-    =
-    ([^\|]+) # fieldname (table.row or row)
+    ([^=\|]+) # header
+    =?
+    ([^\|]*) # fieldname (table.row or row)
     \|? /gxms
 ) {
-    push @headers, $1;
-    my $field = $2;
-    $field =~ s/[^\.]*\.?//; # Remove the table name if exists.
+    my $header = $1;
+    my $field = ($2 eq '') ? $1 : $2;
+
+    $header =~ s/^\s+|\s+$//g; # Trim whitespaces
+    push @headers, $header;
+
+    $field =~ s/[^.]+\.//; # Remove the table name if exists.
+    $field =~ s/^\s+|\s+$//g; # Trim whitespaces
     push @fields, $field;
 }