From ac23c452b899ea8cee891b782aa7aa21325a0b49 Mon Sep 17 00:00:00 2001 From: Evan Carroll Date: Sun, 28 Sep 2008 22:04:20 -0500 Subject: [PATCH] added verbose option --- Changes | 2 ++ lib/DataExtract/FixedWidth.pm | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 18ce4ae..8426a49 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for DataExtract-FixedWidth +0.08 Added verbose option for constructor, helps out a we' bit + 0.07 Bug fix: No longer have to have the first row the longest when using euristic test provided t/11 diff --git a/lib/DataExtract/FixedWidth.pm b/lib/DataExtract/FixedWidth.pm index 64c7b21..4cb7f75 100644 --- a/lib/DataExtract/FixedWidth.pm +++ b/lib/DataExtract/FixedWidth.pm @@ -86,6 +86,8 @@ has 'skip_header_data' => ( , default => 1 ); +has 'verbose' => ( isa => 'Bool', 'is' => 'ro', default => 0 ); + sub _heuristic_trigger { my ( $self, $data ) = @_; @@ -251,10 +253,13 @@ sub parse { chomp $data; ## skip_header_data - return undef - if $self->skip_header_data + if ( + $self->skip_header_data && ( defined $self->header_row && $data eq $self->header_row ) - ; + ) { + warn "Skipping duplicate header row\n" if $self->verbose; + return undef + } #printf "\nData:|%s|\tHeader:|%s|", $data, $self->header_row; @@ -412,6 +417,10 @@ This will permit you to explicitly list the columns in the header row. This is e If a C option is not provided the assumption is that there are no spaces in the column header. The module can take care of the rest. The only way this column can be avoided is if we deduce the header from heuristics, or if you explicitly supply the unpack string and only use C<-Eparse($line)>. If you are not going to supply a header, and you do not want to waste the first line on a header assumption, set the C undef> in the constructor. +=item verbose => 1|0 + +Right now, it simply display's warnings when it does something that might at first seem awkward. Like returning undef when it encouters a duplicate copy of a header row. + =back =head2 Methods -- 2.11.4.GIT