From 959ca19eae26b0418566c8b58ebb0ec265d0e507 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 1 May 2015 17:56:07 -0400 Subject: [PATCH] Bug 14115: Silence warnings in t/Label* Two functions were triggering noisy warnings while testing: _get_text_fields and _split_lccn. TEST PLAN ---------- 1) $ prove t/Label* -- several warnings 2) apply patch 3) $ prove t/Label* -- no warnings 4) koha qa test tools. Signed-off-by: Bernardo Gonzalez Kriegel Nicer, no koha-qa errors --- C4/Labels/Label.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 83093a4..3b4318a 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -115,7 +115,7 @@ sub _get_text_fields { my $csv = Text::CSV_XS->new({allow_whitespace => 1}); my $status = $csv->parse($format_string); my @sorted_fields = map {{ 'code' => $_, desc => $_ }} - map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653 + map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653 $csv->fields(); my $error = $csv->error_input(); warn sprintf('Text field sort failed with this error: %s', $error) if $error; @@ -129,10 +129,11 @@ sub _split_lccn { # lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996'; my @parts = Library::CallNumber::LC->new($lccn)->components(); unless (scalar @parts && defined $parts[0]) { - warn sprintf('regexp failed to match string: %s', $_); + $debug and warn sprintf('regexp failed to match string: %s', $_); @parts = $_; # if no match, just use the whole string. } - push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces + my $LastPiece = pop @parts; + push @parts, split /\s+/, $LastPiece if $LastPiece; # split the last piece into an arbitrary number of pieces at spaces $debug and warn "split_lccn array: ", join(" | ", @parts), "\n"; return @parts; } -- 2.1.4