Kompatibilität mit Text::CSV_XS >= 0.89
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 30 May 2013 10:23:16 +0000 (12:23 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 30 May 2013 10:23:16 +0000 (12:23 +0200)
SL/Helper/Csv.pm

index e481614..2d454be 100644 (file)
@@ -3,6 +3,7 @@ package SL::Helper::Csv;
 use strict;
 use warnings;
 
+use version 0.77;
 use Carp;
 use IO::File;
 use Params::Validate qw(:all);
@@ -156,11 +157,19 @@ sub _parse_data {
       push @data, \%hr;
     } else {
       last if $self->_csv->eof;
-      push @errors, [
-        $self->_csv->error_input,
-        $self->_csv->error_diag,
-        $self->_io->input_line_number,
-      ];
+      # Text::CSV_XS 0.89 added record number to error_diag
+      if (qv(Text::CSV_XS->VERSION) >= qv('0.89')) {
+        push @errors, [
+          $self->_csv->error_input,
+          $self->_csv->error_diag,
+        ];
+      } else {
+        push @errors, [
+          $self->_csv->error_input,
+          $self->_csv->error_diag,
+          $self->_io->input_line_number,
+        ];
+      }
     }
     last if $self->_csv->eof;
   }