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>.
26 C4::ClassSplitRoutine::Dewey - Dewey call number split method
30 use C4::ClassSplitRoutine;
32 my $cn_split = C4::ClassSplitRoutine::Dewey::split_callnumber($cn_item);
36 =head2 split_callnumber
38 my $cn_split = C4::ClassSplitRoutine::Dewey::split_callnumber($cn_item);
42 sub split_callnumber
{
45 my $possible_decimal =
46 qr/\d{3,}(?:\.\d+)?/; # at least three digits for a DDCN
49 ; # in theory we should be able to simply remove all segmentation markers and arrive at the correct call number...
50 my (@lines) = $cn_item =~ m
/
51 ^([-a
-zA
-Z
]*\s?
(?
:$possible_decimal)?
) # R220.3 CD-ROM 787.87 # will require extra splitting
53 (.+) # H2793Z H32 c.2 EAS # everything else (except bracketing spaces)
57 warn sprintf( 'regexp failed to match string: %s', $cn_item );
58 push @lines, $cn_item; # if no match, just push the whole string.
61 if ( $lines[0] =~ /^([-a-zA-Z]+)\s?($possible_decimal)$/ ) {
62 shift @lines; # pull off the mathching first element, like example 1
63 unshift @lines, $1, $2; # replace it with the two pieces
66 push @lines, split /\s+/,
68 ; # split the last piece into an arbitrary number of pieces at spaces
69 $debug and print STDERR
"split_ddcn array: ", join( " | ", @lines ), "\n";
77 Koha Development Team <http://koha-community.org/>