Subject: | trim should not trim trailing whitespace on a line |
The 'trim' method gets a little overzealous and trims trailing and
leading spaces from lines. If the last field in a line is a blank, it
will remove this field. 'trim' should only trim each individual field,
no need to trim the line itself. Attached is a .diff that fixes this
problem.
Subject: | trim.diff |
--- /usr/local/lib/perl5/site_perl/5.10.0/Text/RecordParser.pm 2008-08-30 17:01:08.000000000 -0700
+++ RecordParser.pm 2006-05-18 13:35:22.000000000 -0700
@@ -445,6 +445,7 @@
defined( $line = <$fh> ) or return;
chomp $line;
next if $comment and $line =~ $comment;
+ $line =~ s/^\s+|\s+$//g if $self->trim;
last if $line;
}
@@ -465,8 +466,7 @@
}
if ( $self->trim ) {
- @fields = map { defined $_ && s/^\s+|\s+$//g; $_ } @fields;
-
+ @fields = map { s/^\s+|\s+$//g; $_ } @fields;
}
while ( my ( $position, $callback ) = each %{ $self->field_compute } ) {
@@ -571,7 +571,6 @@
=cut
my $self = shift;
-
my %args
= defined $_[0] && ref $_[0] eq 'HASH' ? %{ shift() }
: @_ % 2 == 0 ? @_