Bug 22944: avoid AnonymousPatron in search_patrons_to_anonymise
[koha.git] / C4 / ClassSplitRoutine / LCC.pm
1 package C4::ClassSplitRoutine::LCC;
2
3 # Copyright 2018 Koha Development Team
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21 use Library::CallNumber::LC;
22
23 use C4::Debug;
24
25 =head1 NAME
26
27 C4::ClassSplitRoutine::LCC - LCC call number split method
28
29 =head1 SYNOPSIS
30
31 use C4::ClassSplitRoutine;
32
33 my $cn_split = C4::ClassSplitRoutine::LCC::split_callnumber($cn_item);
34
35 =head1 FUNCTIONS
36
37 =head2 split_callnumber
38
39   my $cn_split = C4::ClassSplitRoutine::LCC::split_callnumber($cn_item);
40
41 =cut
42
43 sub split_callnumber {
44     my ($cn_item) = @_;
45     # lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
46     my @lines = Library::CallNumber::LC->new($cn_item)->components();
47     unless (scalar @lines && defined $lines[0])  {
48         $debug and warn sprintf('regexp failed to match string: %s', $cn_item);
49         @lines = $cn_item;     # if no match, just use the whole string.
50     }
51     my $LastPiece = pop @lines;
52     push @lines, split /\s+/, $LastPiece if $LastPiece;   # split the last piece into an arbitrary number of pieces at spaces
53     $debug and warn "split LCC array: ", join(" | ", @lines), "\n";
54     return @lines;
55 }
56
57 1;
58
59 =head1 AUTHOR
60
61 Koha Development Team <http://koha-community.org/>
62
63 =cut