View | Details | Raw Unified | Return to bug 9370
Collapse All | Expand All

(-)a/C4/Labels/Label.pm (-12 / +4 lines)
Lines 7-12 use Text::Wrap; Link Here
7
use Algorithm::CheckDigits;
7
use Algorithm::CheckDigits;
8
use Text::CSV_XS;
8
use Text::CSV_XS;
9
use Data::Dumper;
9
use Data::Dumper;
10
use Library::CallNumber::LC;
10
11
11
use C4::Context;
12
use C4::Context;
12
use C4::Debug;
13
use C4::Debug;
Lines 113-130 sub _split_lccn { Link Here
113
    my ($lccn) = @_;
114
    my ($lccn) = @_;
114
    $_ = $lccn;
115
    $_ = $lccn;
115
    # lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
116
    # lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
116
    my (@parts) = m/
117
    my @parts = Library::CallNumber::LC->new($lccn)->components();
117
        ^([a-zA-Z]+)      # HE          # BS
118
    unless (scalar @parts && defined $parts[0])  {
118
        (\d+(?:\.\d)*)    # 8700.7      # 2545
119
        \s*
120
        (\.*\D+\d*)       # .P6         # .E8
121
        \s*
122
        (.*)              # T44 1983    # H39 1996   # everything else (except any bracketing spaces)
123
        \s*
124
        /x;
125
    unless (scalar @parts)  {
126
        warn sprintf('regexp failed to match string: %s', $_);
119
        warn sprintf('regexp failed to match string: %s', $_);
127
        push @parts, $_;     # if no match, just push the whole string.
120
        @parts = $_;     # if no match, just use the whole string.
128
    }
121
    }
129
    push @parts, split /\s+/, pop @parts;   # split the last piece into an arbitrary number of pieces at spaces
122
    push @parts, split /\s+/, pop @parts;   # split the last piece into an arbitrary number of pieces at spaces
130
    $debug and warn "split_lccn array: ", join(" | ", @parts), "\n";
123
    $debug and warn "split_lccn array: ", join(" | ", @parts), "\n";
131
- 

Return to bug 9370