1Library::CallNumber::LCU(s3e)r Contributed Perl DocumentaLtiibornary::CallNumber::LC(3)
2
3
4
6 Library::CallNumber::LC - Deal with Library-of-Congress call numbers
7
9 Version 0.23;
10
12 Utility functions to deal with Library of Congress Call Numbers
13
14 use Library::CallNumber::LC;
15 my $a = Library::CallNumber::LC->new('A 123.4 .c11');
16 print $a->normalize; # normalizes for string comparisons.
17 # gives 'A01234 C11'
18 print $a->start_of_range; # same as "normalize"
19 my $b = Library::CallNumber::LC->new('B11 .c13 .d11');
20 print $b->normalize;
21 # gives 'B0011 C13 D11'
22 my @range = ($a->start_of_range, $b->end_of_range);
23 # end of range is 'B0011 C13 D11~'
24
25 # Get components suitable for printing (e.g., number and decimal joined, leading dot on first cutter)
26 @comps = Library::CallNumber::LC->new('A 123.4 .c11')->components()
27
28 # Same thing, but return empty strings for missing components (e.g., the cutters)
29 @comps = Library::CallNumber::LC->new('A 123.4 .c11')->components('true');
30
32 Library::CallNumber::LC is mostly designed to do call number
33 normalization, with the following goals:
34
35 • The normalized call numbers are comparable with each other, for
36 proper sorting
37
38 • The normalized call number is a short as possible, so left-anchored
39 wildcard searches are possible (e.g., searching on "A11*" should
40 give you all the A11 call numbers)
41
42 • A range defined by start_of_range and end_of_range should be
43 correct, assuming that the string given for the end of the range
44 is, in fact, a left prefix.
45
46 That last point needs some explanation. The idea is that if someone
47 gives a range of, say, A-AZ, what they really mean is A - AZ9999.99.
48 The end_of_range method generates a key which lies immediately beyond
49 the last possible key for a given starting point. There is no attempt
50 to make end_of_range normalization correspond to anything in real life.
51
53 new([call_number_text, [topper_character, [bottomer_character]]]) -- create
54 a new object, optionally passing in the initial string, a "topper", and
55 a "bottomer" (explained below)
57 call_number([call_number_text])
58 The text of the call number we are dealing with.
59
60 topper([character])
61 Specify which character occupies the 'always-sort-to-the-top' slots in
62 the sort keys. Defaults to the SPACE character, but can reasonably be
63 anything with an ASCII value lower than 48 (i.e. the 'zero' character,
64 '0'). This can function as either a class or instance method depending
65 on need.
66
67 bottomer([character])
68 Specify which character occupies the 'always-sort-to-the-bottom' slots
69 in the sort keys. Defaults to the TILDE character, but can reasonably
70 be anything with an ASCII value higher than 90 (i.e. 'Z'). This can
71 function as either a class or instance method depending on need.
72
74 components(boolean returnAll = false)
75 @comps = Library::CallNumber::LC->new('A 123.4 .c11')->components($returnAll)
76
77 Returns an array of the individual components of the call number (or
78 undef if it doesn't look like a call number). Components are:
79
80 • alpha
81
82 • number (numeric.decimal)
83
84 • cutter1
85
86 • cutter2
87
88 • cutter3
89
90 • "extra" (anything after the cutters)
91
92 The optional argument <I returnAll> (false by default) determines
93 whether or not empty components (e.g., extra cutters) get a slot in the
94 returned list.
95
96 _normalize(call_number_text)
97 Base function to perform normalization.
98
99 normalize([call_number_text])
100 Normalize the stored or passed call number as a sortable string
101
102 start_of_range([call_number_text])
103 Alias for normalize
104
105 end_of_range([call_number_text])
106 Downshift an lc number so it represents the end of a range
107
108 toLongInt(call_number_text, num_digits)
109 Attempt to turn a call number into an integer value. Possibly useful
110 for fast range checks, although obviously not perfectly accurate.
111 Optional argument $num_digits can be used to control the number of
112 digits used, and therefore the precision of the results.
113
115 Current Maintainer: Dan Wells, "<dbw2 at calvin.edu>" Original Author:
116 Bill Dueber, "<dueberb at umich.edu>"
117
119 Please report any bugs or feature requests through the web interface at
120 <http://code.google.com/p/library-callnumber-lc/issues/list>. I will
121 be notified, and then you'll automatically be notified of progress on
122 your bug as I make changes.
123
125 You can find documentation for this module with the perldoc command.
126
127 perldoc Library::CallNumber::LC
128
129 You can also look for information at the Google Code page:
130
131 http://code.google.com/p/library-callnumber-lc/
132
134 Copyright 2009 Bill Dueber, all rights reserved. Copyright 2011 Dan
135 Wells, all rights reserved.
136
137 This program is free software; you can redistribute it and/or modify it
138 under the same terms as Perl itself and also under the new BSD license
139 as described at http://www.opensource.org/licenses/bsd-license.php
140
141
142
143perl v5.36.0 2023-01-20 Library::CallNumber::LC(3)