1 package C4::ClassSplitRoutine::Dewey;
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>.
24 C4::ClassSplitRoutine::Dewey - Dewey call number split method
28 use C4::ClassSplitRoutine;
30 my $cn_split = C4::ClassSplitRoutine::Dewey::split_callnumber($cn_item);
34 =head2 split_callnumber
36 my $cn_split = C4::ClassSplitRoutine::Dewey::split_callnumber($cn_item);
40 sub split_callnumber {
43 my $possible_decimal =
44 qr/\d{3,}(?:\.\d+)?/; # at least three digits for a DDCN
47 ; # in theory we should be able to simply remove all segmentation markers and arrive at the correct call number...
48 my (@lines) = $cn_item =~ m/
49 ^([-a-zA-Z]*\s?(?:$possible_decimal)?) # R220.3 CD-ROM 787.87 # will require extra splitting
51 (.+) # H2793Z H32 c.2 EAS # everything else (except bracketing spaces)
55 warn sprintf( 'regexp failed to match string: %s', $cn_item );
56 push @lines, $cn_item; # if no match, just push the whole string.
59 if ( $lines[0] =~ /^([-a-zA-Z]+)\s?($possible_decimal)$/ ) {
60 shift @lines; # pull off the mathching first element, like example 1
61 unshift @lines, $1, $2; # replace it with the two pieces
64 push @lines, split /\s+/,
66 ; # split the last piece into an arbitrary number of pieces at spaces
74 Koha Development Team <http://koha-community.org/>