Biblio-LCC
view release on metacpan or search on metacpan
script/lccnorm view on Meta::CPAN
$PAGER = $ENV{'PAGER'} || which(qw(less more)) || which('cat') || 0;
return $PAGER;
}
sub podder {
return "cat $0 | pod2man -n $PROGRAM -s 1 -r $VERSION -c '' | nroff -man | " . pager()
if pager() and which('pod2man') and which('nroff');
return "man 1 $PROGRAM"
if manpage($PROGRAM);
return "perldoc -F $0"
if which('perldoc');
return undef;
}
sub which {
my $out;
no warnings;
foreach my $prog (@_) {
$out = `which $prog 2>/dev/null`;
if (defined $out) {
chomp $out;
return $out if -x $out;
}
}
return undef;
}
sub manpage {
return unless which('man');
my $out = `man -w 1 $PROGRAM 2>/dev/null`;
return unless defined $out;
chomp $out;
return $out;
}
=head1 NAME
lccnorm - normalize Library of Congress Classification call numbers
=head1 SYNOPSIS
B<lccnorm> [I<option>...] [I<file>...]
B<lccnorm> B<-h>|B<--help>
B<lccnorm> B<-V>|B<--version>
=head1 DESCRIPTION
B<lccnorm> transforms LC-style call numbers into a form that may be used in a
straight ASCII sort.
By default, each line of input is assumed to consist of a number of
tab-delimited fields, of which the first contains an LC-style call number or
class.
If no file is specified, or if the file name C<-> is specified, standard input
will be processed.
Normalization of call number ranges is a special challenge, because ranges are
not normally specified using the exact endpoint. Consider the range C<B708-B713>; while
C<B708> does indicate the beginning point -- a no call number that comes before B 708 can
fall within the range -- the end point is only a guide, not a strict limit, since the intent
is that call numbers such as C<B 713 .H94> and C<B 713 .W55 L86> B<do> fall within the
range. Unfortunately, ranges are often specified ambiguously; for example, the call number
C<B 713.14 G92> might or might not be considered to fall within this range.
=head1 OPTIONS
=over 4
=item B<-d>, B<--delimiter> I<string>
Specify a string other than a single tab (ASCII character 9) to delimit the
fields in a line of input. This also provides the default for joining fields
in the output; see option B<-j> below.
=item B<-f>, B<--field> I<range>
The call number (or range) is found in the given range of fields. Fields are
1-based (the first field is field 1, not field 0) and are separated by a single
tab character (unless option B<-d> is used to specify an alternate delimiter).
When parsing call numbers (not ranges), all fields are concatenated using a
single space to form the call number that will be normalized.
When parsing ranges, there are four possibilities:
=over 4
=item 1 field
The field contains a range in the form I<prefix> (e.g., C<J80>), I<closed
range> (e.g., C<ML566-566.6> or C<ML566-ML566.6>) or I<half-open range> (e.g.,
C<< KME451E<lt>KME500 >>).
=item 2 fields
The first field is the beginning of the (closed) range, and the second is the
end.
=item 3 fields
The first field is a prefix common to both the beginning and end of the range,
and the second and third fields are the remainders.
=item 4 fields
The first and third fields together are the beginning of the range, and the
second and fourth are the end.
=back
For example, the following all produce identical output:
$ echo 'PL4501-4509' | lccnorm -d: -f1
$ echo 'PL4501:PL4509' | lccnorm -d: -f1-2
$ echo 'PL:4501:4509' | lccnorm -d: -f1-3
$ echo 'PL:4501:PL:4509' | lccnorm -d: -f1-4
=item B<-j>, B<--join> I<string>
( run in 2.695 seconds using v1.01-cache-2.11-cpan-524268b4103 )