Perl extension for international standard serial numbers
use Business::ISSN; $issn_object = Business::ISSN->new('1456-5935'); $issn_object = Business::ISSN->new('14565935'); # print the ISSN (with hyphen) print $issn_object->as_string; # check to see if the ISSN is valid $issn_object->is_valid; #fix the ISSN checksum. BEWARE: the error might not be #in the checksum! $issn_object->fix_checksum; #EXPORTABLE FUNCTIONS use Business::ISSN qw( is_valid_checksum ); #verify the checksum if( is_valid_checksum('01234567') ) { ... }
The constructor accepts a scalar representing the \s-1ISSN\s0. The string representing the \s-1ISSN\s0 may contain characters other than [0-9xX], although these will be removed in the internal representation. The resulting string must look like an \s-1ISSN\s0 - the first seven characters must be digits and the eighth character must be a digit, 'x', or 'X'. The string passed as the \s-1ISSN\s0 need not be a valid \s-1ISSN\s0 as long as it superficially looks like one. This allows one to use the \*(C`fix_checksum\*(C' method. One should check the validity of the \s-1ISSN\s0 with \*(C`is_valid()\*(C' rather than relying on the return value of the constructor. If all one wants to do is check the validity of an \s-1ISSN\s0, one can skip the object-oriented interface and use the c<is_valid_checksum()> function which is exportable on demand. If the constructor decides it can't create an object, it returns undef. It may do this if the string passed as the \s-1ISSN\s0 can't be munged to the internal format. Return the \s-1ISSN\s0 checksum. Return the \s-1ISSN\s0 as a string. A terminating 'x' is changed to 'X'. Returns 1 if the checksum is valid. Returns 0 if the \s-1ISSN\s0 does not pass the checksum test. The constructor accepts invalid \s-1ISSN\s0's so that they might be fixed with \*(C`fix_checksum\*(C'. Replace the eighth character with the checksum the corresponds to the previous seven digits. This does not guarantee that the \s-1ISSN\s0 corresponds to the product one thinks it does, or that the \s-1ISSN\s0 corresponds to any product at all. It only produces a string that passes the checksum routine. If the \s-1ISSN\s0 passed to the constructor was invalid, the error might have been in any of the other nine positions.
Some functions can be used without the object interface. These do not use object technology behind the scenes.
Takes the \s-1ISSN\s0 string and runs it through the checksum comparison routine. Returns 1 if the \s-1ISSN\s0 is valid, 0 otherwise.
Currently maintained by brian d foy \*(C`<[email protected]>\*(C'. Sami Poikonen <[email protected]>
Original module by Sami Poikonen, based on Business::ISBN by brian d foy.
This module is released under the terms of the Perl Artistic License.
Copyright (c) 1999-2008, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.