Current File : //usr/local/share/man/man3/Business::ISBN.3
.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Business::ISBN 3"
.TH Business::ISBN 3 "2014-09-21" "perl v5.20.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Business::ISBN \- work with International Standard Book Numbers
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&        use Business::ISBN;
\&
\&        # 10 digit ISBNs
\&        $isbn10 = Business::ISBN\->new(\*(Aq1565922573\*(Aq);
\&        $isbn10 = Business::ISBN\->new(\*(Aq1\-56592\-257\-3\*(Aq);
\&
\&        # 13 digit ISBNs
\&        $isbn13 = Business::ISBN\->new(\*(Aq978\-0\-596\-52724\-2\*(Aq);
\&
\&        # convert
\&        $isbn10 = $isbn13\->as_isbn10;    # for the 978 prefixes
\&
\&        $isbn13 = $isbn10\->as_isbn13;
\&
\&        # maybe you don\*(Aqt care what it is as long as everything works
\&        $isbn = Business::ISBN\->new( $ARGV[0] );
\&
\&        #print the ISBN with hyphens at usual positions
\&        print $isbn\->as_string;
\&
\&        #print the ISBN with hyphens at specified positions.
\&        #this not does affect the default positions
\&        print $isbn\->as_string([]);
\&
\&        #print the group code or publisher code
\&        print $isbn\->group_code;
\&
\&        print $isbn\->publisher_code;
\&
\&        #check to see if the ISBN is valid
\&        $isbn\->is_valid;
\&
\&        #fix the ISBN checksum.  BEWARE:  the error might not be
\&        #in the checksum!
\&        $isbn\->fix_checksum;
\&
\&        # create an EAN13 barcode in PNG format
\&        $isbn\->png_barcode;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This modules handles International Standard Book Numbers, including
\&\s-1ISBN\-10\s0 and \s-1ISBN\-13.\s0
.SS "Function interface"
.IX Subsection "Function interface"
.IP "valid_isbn_checksum( \s-1ISBN10\s0 | \s-1ISBN13 \s0)" 4
.IX Item "valid_isbn_checksum( ISBN10 | ISBN13 )"
This function is exportable on demand, and works for either 10
or 13 character ISBNs).
.Sp
.Vb 1
\&        use Business::ISBN qw( valid_isbn_checksum );
.Ve
.Sp
Returns 1 if the \s-1ISBN\s0 is a valid \s-1ISBN\s0 with the right checksum.
.Sp
Returns 0 if the \s-1ISBN\s0 has valid prefix and publisher codes, but an
invalid checksum.
.Sp
Returns undef if the \s-1ISBN\s0 does not validate for any other reason.
.SS "Object interface"
.IX Subsection "Object interface"
.IP "new($isbn)" 4
.IX Item "new($isbn)"
The constructor accepts a scalar representing the \s-1ISBN.\s0
.Sp
The string representing the \s-1ISBN\s0 may contain characters other than
\&\f(CW\*(C`[0\-9xX]\*(C'\fR, although these will be removed in the internal
representation.  The resulting string must look like an \s-1ISBN \-\s0 the
first nine characters must be digits and the tenth character must be a
digit, 'x', or 'X'.
.Sp
The constructor attempts to determine the group code and the publisher
code.  If these data cannot be determined, the constructor sets \f(CW\*(C`$obj\->error\*(C'\fR to something other than \f(CW\*(C`GOOD_ISBN\*(C'\fR. An object is
still returned and it is up to the program to check \f(CW\*(C`$obj\->error\*(C'\fR
for one of five values (which may be exported on demand). The actual
values of these symbolic versions are the same as those from previous
versions of this module which used literal values.
.Sp
.Vb 5
\&        Business::ISBN::INVALID_PUBLISHER_CODE
\&        Business::ISBN::INVALID_GROUP_CODE
\&        Business::ISBN::BAD_CHECKSUM
\&        Business::ISBN::GOOD_ISBN
\&        Business::ISBN::BAD_ISBN
.Ve
.Sp
If you have one of these values and want to turn it into a string, you
can use the \f(CW%Business::ISBN::ERROR_TEXT\fR hash, which is exportable
by asking for it explicitly in the import list.
.Sp
.Vb 1
\&        use Business::ISBN qw(%ERROR_TEXT);
.Ve
.Sp
The string passed as the \s-1ISBN\s0 need not be a valid \s-1ISBN\s0 as long as it
superficially looks like one.  This allows one to use the
\&\f(CW\*(C`fix_checksum()\*(C'\fR method.  Despite the disclaimer in the discussion of
that method, the author has found it extremely useful.  One should
check the validity of the \s-1ISBN\s0 with \f(CW\*(C`is_valid()\*(C'\fR rather than relying
on the return value of the constructor.  If all one wants to do is
check the validity of an \s-1ISBN,\s0 one can skip the object-oriented
interface and use the \f(CW\*(C`valid_isbn_checksum()\*(C'\fR function which is
exportable on demand.
.Sp
If the constructor decides it cannot create an object, it returns
\&\f(CW\*(C`undef\*(C'\fR.  It may do this if the string passed as the \s-1ISBN\s0 cannot be
munged to the internal format meaning that it does not even come close
to looking like an \s-1ISBN.\s0
.SS "Instance methods"
.IX Subsection "Instance methods"
.IP "input_isbn" 4
.IX Item "input_isbn"
Returns the starting \s-1ISBN.\s0 Since you may insert hyphens or fix
checksums, you might want to see the original data.
.IP "common_data" 4
.IX Item "common_data"
Returns the starting \s-1ISBN\s0 after normalization, which removes anything
that isn't a digit or a valid checksum character.
.IP "isbn" 4
.IX Item "isbn"
Returns the current value of \s-1ISBN,\s0 even if it has an invalid checksum.
This is the raw data so it doesn't have the hyphens. If you want
hyphenation, try \f(CW\*(C`as_string\*(C'\fR.
.Sp
The \f(CW\*(C`isbn\*(C'\fR method should be the same as \f(CW\*(C`as_string( [] )\*(C'\fR.
.IP "error" 4
.IX Item "error"
Return the error code for the reason the \s-1ISBN\s0 isn't valid. The return
value is a key in \f(CW%ERROR_TEXT\fR.
.IP "is_valid" 4
.IX Item "is_valid"
Return true if the \s-1ISBN\s0 is valid, meaning that it has a valid prefix
(for \s-1ISBN\-13\s0), group code, and publisher code; and its checksum
validates.
.IP "type" 4
.IX Item "type"
Returns either \f(CW\*(C`ISBN10\*(C'\fR or \f(CW\*(C`ISBN13\*(C'\fR.
.IP "prefix" 4
.IX Item "prefix"
Returns the prefix for the \s-1ISBN.\s0 This is currently either 978 or 979
for \s-1ISBN\-13.\s0 It returns the empty string (so, a defined value) for
\&\s-1ISBN\-10.\s0
.IP "group_code" 4
.IX Item "group_code"
Returns the group code for the \s-1ISBN.\s0 This is the numerical version,
for example, '0' for the English group. The valid group codes come
from \f(CW\*(C`Business::ISBN::Data\*(C'\fR.
.IP "group" 4
.IX Item "group"
Returns the group name for the \s-1ISBN.\s0 This is the string version. For
instance, 'English' for the '0' group. The names come from
\&\f(CW\*(C`Business::ISBN::Data\*(C'\fR.
.IP "publisher_code" 4
.IX Item "publisher_code"
Returns the publisher code for the \s-1ISBN.\s0 This is the numeric version,
for instance '596' for O'Reilly Media.
.IP "article_code" 4
.IX Item "article_code"
Returns the article code for the \s-1ISBN.\s0 This is the numeric version that
uniquely identifies the item.
.IP "article_code_length" 4
.IX Item "article_code_length"
Returns the article code length for the \s-1ISBN.\s0
.IP "article_code_min" 4
.IX Item "article_code_min"
Returns the minimum article code length for the publisher code.
.IP "article_code_max" 4
.IX Item "article_code_max"
Returns the max article code length for the publisher code.
.IP "checksum" 4
.IX Item "checksum"
Returns the checksum code for the \s-1ISBN.\s0 This checksum may not be valid since
you can create an object an fix the checksum later with \f(CW\*(C`fix_checksum\*(C'\fR.
.IP "is_valid_checksum" 4
.IX Item "is_valid_checksum"
Returns \f(CW\*(C`Business::ISBN::GOOD_ISBN\*(C'\fR for valid checksums and
\&\f(CW\*(C`Business::ISBN::BAD_CHECKSUM\*(C'\fR otherwise. This does not guarantee
that the rest of the \s-1ISBN\s0 is actually assigned to a book.
.IP "fix_checksum" 4
.IX Item "fix_checksum"
Checks the checksum and modifies the \s-1ISBN\s0 to set it correctly if needed.
.IP "\fIas_string()\fR, as_string([])" 4
.IX Item "as_string(), as_string([])"
Return the \s-1ISBN\s0 as a string.  This function takes an
optional anonymous array (or array reference) that specifies
the placement of hyphens in the string.  An empty anonymous array
produces a string with no hyphens. An empty argument list
automatically hyphenates the \s-1ISBN\s0 based on the discovered
group and publisher codes.  An \s-1ISBN\s0 that is not valid may
produce strange results.
.Sp
The positions specified in the passed anonymous array
are only used for one method use and do not replace
the values specified by the constructor. The method
assumes that you know what you are doing and will attempt
to use the least three positions specified.  If you pass
an anonymous array of several positions, the list will
be sorted and the lowest three positions will be used.
Positions less than 1 and greater than 12 are silently
ignored.
.Sp
A terminating 'x' is changed to 'X'.
.IP "as_isbn10" 4
.IX Item "as_isbn10"
Returns a new \s-1ISBN\s0 object. If the object is already \s-1ISBN\-10,\s0 this method
clones it. If it is an \s-1ISBN\-13\s0 with the prefix 978, it returns the \s-1ISBN\-10\s0
equivalent. For all other cases it returns undef.
.IP "as_isbn13" 4
.IX Item "as_isbn13"
Returns a new \s-1ISBN\s0 object. If the object is already \s-1ISBN\-13,\s0 this method
clones it. If it is an \s-1ISBN\-10,\s0 it returns the \s-1ISBN\-13\s0 equivalent with the
978 prefix.
.IP "xisbn" 4
.IX Item "xisbn"
In scalar context, returns an anonymous array of related ISBNs using xISBN.
In list context, returns a list.
.Sp
This feature requires \f(CW\*(C`LWP::Simple\*(C'\fR.
.IP "increment" 4
.IX Item "increment"
Returns the next \f(CW\*(C`Business::ISBN\*(C'\fR by incrementing the article code of
the specified \s-1ISBN \s0(object or scalar).
.Sp
Returns undef, if the parameter is invalid or equals the maximum
possible \s-1ISBN\s0 for the publisher.
.Sp
.Vb 2
\&        $isbn = Business::ISBN\->new(\*(Aq1565922573\*(Aq);  # 1\-56592\-257\-3
\&        $next_isbn = $isbn\->increment;              # 1\-56592\-258\-1
.Ve
.Sp
If the next article code would exceed the maximum possible article
code (such as incrementing 999 to 1000), this returns \s-1ARTICLE_CODE_OUT_OF_RANGE\s0
as the error.
.IP "decrement" 4
.IX Item "decrement"
Returns the previous \f(CW\*(C`Business::ISBN\*(C'\fR by decrementing the article
code of the specified \s-1ISBN \s0(object or scalar).
.Sp
Returns undef, if the parameter is invalid or equals the minimum
possible \s-1ISBN\s0 for the publisher.
.Sp
.Vb 2
\&        $isbn = Business::ISBN\->new(\*(Aq1565922573\*(Aq);  # 1\-56592\-257\-3
\&        $prev_isbn = $isbn\->decrement;              # 1\-56592\-256\-5
.Ve
.Sp
If the next article code would exceed the maximum possible article
code (such as incrementing 000 to \-1), this returns \s-1ARTICLE_CODE_OUT_OF_RANGE\s0
as the error.
.IP "png_barcode" 4
.IX Item "png_barcode"
Returns image data in \s-1PNG\s0 format for the barcode for the \s-1ISBN.\s0 This
works with \s-1ISBN\-10\s0 and \s-1ISBN\-13.\s0 The ISBN\-10s are automaically converted
to \s-1ISBN\-13.\s0
.Sp
This requires \f(CW\*(C`GD::Barcode::EAN13\*(C'\fR.
.SH "BUGS"
.IX Header "BUGS"
.SH "TO DO"
.IX Header "TO DO"
* i would like to create the bar codes with the price extension
.SH "SOURCE AVAILABILITY"
.IX Header "SOURCE AVAILABILITY"
This source is in Github:
.PP
.Vb 1
\&    https://github.com/briandfoy/business\-\-isbn
.Ve
.SH "AUTHOR"
.IX Header "AUTHOR"
brian d foy \f(CW\*(C`<bdfoy@cpan.org>\*(C'\fR
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
Copyright (c) 2001\-2014, brian d foy, All Rights Reserved.
.PP
You may redistribute this under the same terms as Perl itself.
.SH "CREDITS"
.IX Header "CREDITS"
Thanks to Mark W. Eichin \f(CW\*(C`<eichin@thok.org>\*(C'\fR for suggestions and
discussions on \s-1EAN\s0 support.
.PP
Thanks to Andy Lester \f(CW\*(C`<andy@petdance.com>\*(C'\fR for lots of bug fixes
and testing.
.PP
Ed Summers \f(CW\*(C`<esummers@cpan.org>\*(C'\fR has volunteered to help with
this module.
.PP
Markus Spann \f(CW\*(C`<markus_spann@gmx.de>\*(C'\fR added \f(CW\*(C`increment\*(C'\fR and \f(CW\*(C`decrement\*(C'\fR.