Bug 18309: UNIMARC update from IFLA - authority (fr) (FA)
[koha.git] / C4 / ClassSplitRoutine / LCC.pm
blob44df19ee237b7cb81b43405d46f8608e5d6c49ec
1 package C4::ClassSplitRoutine::LCC;
3 # Copyright 2018 Koha Development Team
5 # This file is part of Koha.
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.
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.
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>.
20 use Modern::Perl;
21 use Library::CallNumber::LC;
23 use C4::Debug;
25 =head1 NAME
27 C4::ClassSplitRoutine::LCC - LCC call number split method
29 =head1 SYNOPSIS
31 use C4::ClassSplitRoutine;
33 my $cn_split = C4::ClassSplitRoutine::LCC::split_callnumber($cn_item);
35 =head1 FUNCTIONS
37 =head2 split_callnumber
39 my $cn_split = C4::ClassSplitRoutine::LCC::split_callnumber($cn_item);
41 =cut
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.
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;
59 =head1 AUTHOR
61 Koha Development Team <http://koha-community.org/>
63 =cut