From 61a56da0c549380aeaa9d3c04ea8ba56145444b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 7 Mar 2011 12:10:50 +0100 Subject: [PATCH] Bugfix: Kein newline am Ende der Datei verschluckte die letzte Zeile. --- SL/Helper/Csv.pm | 3 ++- t/helper/csv.t | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SL/Helper/Csv.pm b/SL/Helper/Csv.pm index d4a0c8883..e2032ea27 100644 --- a/SL/Helper/Csv.pm +++ b/SL/Helper/Csv.pm @@ -120,18 +120,19 @@ sub _parse_data { while (1) { my $row = $self->_csv->getline($self->_io); - last if $self->_csv->eof; if ($row) { my %hr; @hr{@{ $self->header }} = @$row; push @data, \%hr; } else { + last if $self->_csv->eof; push @errors, [ $self->_csv->error_input, $self->_csv->error_diag, $self->_io->input_line_number, ]; } + last if $self->_csv->eof; } $self->_data(\@data); diff --git a/t/helper/csv.t b/t/helper/csv.t index e54dcb6fc..d4a157199 100644 --- a/t/helper/csv.t +++ b/t/helper/csv.t @@ -1,4 +1,4 @@ -use Test::More tests => 36; +use Test::More tests => 37; use SL::Dispatcher; use Data::Dumper; use utf8; @@ -264,5 +264,14 @@ $csv->parse; is_deeply( ($csv->errors)[0], [ 'description', undef, 'header field \'description\' is not recognized', undef, 0 ], 'strict_profile without ignore_columns throws error'); +##### + +$csv = SL::Helper::Csv->new( + file => \"Kaffee", + header => [ 'description' ], + class => 'SL::DB::Part', +); +$csv->parse; +is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'eol bug at the end of files'; # vim: ft=perl -- 2.20.1