1 package Equinox::Migration::Utils;
3 # Copyright 2014, Equinox Software, Inc.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 our @ISA = qw(Exporter);
28 our @EXPORT_OK = qw(normalize_oclc_number);
31 sub normalize_oclc_number {
39 $str =~ s/^\(OCoLC\)//i;
40 $str =~ s/^(ocl7|ocm|ocn|on)//i;
42 # ... and any leading zeroes
45 if ($str =~ /^\d+$/) {
46 return '(OCoLC)' . $str;
54 Equinox::Migration::Utils - utility functions
58 use Equinox::Migration::Utils qw/normalize_oclc_number/;
59 my $normalized = normalize_oclc_number($oclc);
63 =head2 normalize_oclc_number)
65 my $normalized = normalize_oclc_number($oclc);
67 Returns a normalized form of a string that is assumed to be
68 an OCLC control number. The normalized form consists of the
69 string "(OCoLC)" followed by the numeric portion of the OCLC
70 number, sans leading zeroes.
72 The input string is expected to be a sequence of digits with
73 optional leading and trailing whitespace and an optional prefix
74 from a set observed in the wild, e.g., "(OCoLC)", "ocm", and so
75 forth. If the input string does not meet this condition, the
76 undefined value is returned.
84 Copyright 2014, Equinox Software Inc.