Anirvan Chatterjee > Business-LCCN > Business::LCCN



Annotate this POD


New  1
Open  1
View/Report Bugs
Module Version: 1.01   Source  


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


Version 1.01


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";

      # permalink: ""
      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 ";




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 "" and info URIs like

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 type, either "A" (issued 1898-2000) or "B" (issued 2001-).


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


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


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.


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".


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


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').


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


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.


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".


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


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


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".


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


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 "".

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.




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


Anirvan Chatterjee, <anirvan at>


Please report any bugs or feature requests to bug-business-lccn at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


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

    perldoc Business::LCCN

You can also look for information at:


Copyright 2008 Anirvan Chatterjee, all rights reserved.


syntax highlighting: