The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::LCCN - Work with Library of Congress Control Number (LCCN) codes

VERSION

Version 1.01

SYNOPSIS

Work with Library of Congress Control Number (LCCN) codes.

    use Business::LCCN;

    my $lccn = Business::LCCN->new('he 68001993 /HE/r692');
    if ($lccn) {

      # parse LCCN (common fields)
      print 'Prefix ',         $lccn->prefix,         "\n"; # "he"
      print 'Prefix field ',   $lccn->prefix_encoded, "\n"; # "he "
      print 'Year cataloged ', $lccn->year_cataloged, "\n"; # 1968
      print 'Year field ',     $lccn->year_encoded,   "\n"; # "68"
      print 'Serial ',         $lccn->serial,         "\n"; # "001993"

      # stringify LCCN:

      # canonical format: "he 68001993 /HE/r692"
      print 'Canonical ',     $lccn->canonical,    "\n";

      # simple normalized format: "he68001993"
      print 'Normalized ', $lccn->normalized,"\n";

      # info: URI: "info:lccn:he68001993"
      print 'Info URI ',   $lccn->info_uri,  "\n";

      # lccn.loc.gov permalink: "http://lccn.loc.gov/he68001993"
      print 'Permalink ',  $lccn->permalink,"\n";

      # parse LCCN (uncommon fields)
      print 'LCCN Type ',     $lccn->lccn_structure, "\n"; # "A" or "B"
      print 'Suffix field ',  $lccn->suffix_encoded,  \n"; # "/HE"
      print 'Suffix parts ',  $lccn->suffix_alphabetic_identifiers,
                                                     "\n"; # ("HE")
      print 'Rev year',       $lccn->revision_year,  "\n"; # 1969
      print 'Rev year field ',$lccn->revision_year_encoded,
                                                     "\n"; # "69"
      print 'Rev number ',    $lccn->revision_number,"\n"; # 2

    } else {
        print " Error : Invalid LCCN \n ";
    }

INTERFACE

Methods

new

The new method takes a single encoded LCCN string, in a variety of formats -- with or without hyphens, with proper spacing or without. Examples:

    "89-1234", "89-001234", "89001234", "2002-1234", "2002-001234",
    "2002001234", "   89001234 ", "  2002001234", "a89-1234",
    "a89-001234", "a89001234", "a2002-1234", "a2002-001234",
    "a2002001234", "a  89001234 ", "a 2002001234", "ab98-1234",
    "ab98-001234", "ab98001234", "ab2002-1234", "ab2002-001234",
    "ab2002001234", "ab 98001234 ", "ab 2002001234", "abc89-1234",
    "abc89-001234", "abc89001234", "abc89001234 ", permalinks URLs
    like "http://lccn.loc.gov/2002001234" and info URIs like
    "info:lccn/2002001234"

Returns a Business::LCCN object, or undef if the string can't be parsed as a valid LCCN. If the string can't be parsed, new will warn with a diagnostic message explaining why the string was invalid.

new can also take an optional hashref of options as a second parameter. The only option supported is no_warnings, which will disable any diagnostic warnings explaining why a candidate LCCN string was invalid:

    # returns undef, issues warning about input not containing any digits
    $foo = LCCN->new('x');

    # returns undef, but does not issue any additional warning
    $bar = LCCN->new( 'x', { no_warnings => 1 } );

LCCN attributes

lccn_structure

LCCN structure type, either "A" (issued 1898-2000) or "B" (issued 2001-).

prefix

LCCN's alphabetic prefix, 1-3 characters long. Returns an empty string if LCCN has no prefix.

prefix_encoded

The prefix as encoded, either two (structure A) or three (structure B) characters long, space-padded.

year_cataloged

The year a book was cataloged. Returns an undef in cases where the cataloging year in unclear. For example, LCCN " 75425165 //r75" has a cataloged year of 1975.

year_encoded

A two (structure A) or four (structure B) digit string typically representing the year the book was cataloged, but sometimes serving as a checksum, or a source code. For example, LCCN " 75425165 //r75" has an encoded year field of "75".

serial

A six-digit number zero-padded serial number. For example, LCCN " 75425165 //r75" has a serial number of "425165".

suffix_alphabetic_identifiers

Structure A LCCNs can include one or more 1-3 character suffix/alphabetic identifiers. Returns a list of all identifiers present. For example, for LCCN " 79139101 /AC/MN", suffix_alphabetic_identifiers returns ('AC', 'MN').

suffix_encoded

The LCCN's suffix/alphabetic identifier field, as encoded in the LCCN. Returns an empty string if no suffix present.

revision_year

Structure A LCCNs can include a revision date in their bibliographic records. Returns the four-digit year the record was revised, or undef if not present. For example, LCCN " 75425165 //r75" has a revision year of 1975.

revision_year_encoded

The two-letter revision date, as encoded in structure A LCCNs. Returns an empty string if no revision year present. For example, LCCN " 75425165 //r75" has a revision year of "75".

revision_number

Some structure A LCCNs have a revision year and number, representing the number of times the record has been revised. For example, LCCN " 75425165 //r752" has revision_number 2. Returns undef if not present.

LCCN representations

canonical

Returns the canonical 12+ character default representation of an LCCN. For example, " 85000002 " is the canonical representation of "85000002", "85-000002", "85-2", " 85000002".

normalized

Returns the normalized 9-12 character representation of an LCCN. Normalized LCCNs are often used in URIs and Internet-era representations. For example, "n2001050268" is the normalized representation of "n 85-000002 ", "n85-2", "n 85-0000002".

info_uri

Returns the info: URI for an LCCN. For example, the URI for LCCN "n 85-000002 " is "info:lccn/n85000002".

original

Returns the original representation of the LCCN, as passed to new.

Returns the Library of Congress permalink URL for an LCCN. For example, the permalink URL for LCCN "n 85-000002 " is "http://lccn.loc.gov/n85000002".

Operator overloading

""

In string context, Business::LCCN objects stringify as the canonical representation of the LCCN.

eq, ==

Business::LCCN objects can be compared to other Business::LCCN objects or LCCN strings.

SEE ALSO

Business::ISBN, http://www.loc.gov/marc/lccn_structure.html, http://lccn.loc.gov/, http://www.loc.gov/standards/uri/info.html, http://en.wikipedia.org/wiki/Library_of_Congress_Control_Number

DIAGNOSTICS

Running new on invalid input may generate warnings, unless the no_warnings option is set.

AUTHOR

Anirvan Chatterjee, <anirvan at cpan.org>

BUGS

Please report any bugs or feature requests to bug-business-lccn at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Business-LCCN. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Business::LCCN

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Anirvan Chatterjee, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.