[ Date Index ][
Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]
On Thursday 25 Sep 2003 8:53 pm, Mark Evans wrote: > On Wed, Sep 24, 2003 at 10:16:24PM +0100, Neil Williams wrote: > It would probably be a good idea to allow both the 10 digit ISBN and > the 13 digit "bookland" EAN formats. Since the latter can easily be > obtained from a barcode reader. I've calculated a conversion algorithm and it'll be incorporated into the next release. The algorithm has also provided the checksum calculation I needed for the ISBN itself. For reference, the algorithm is expressed as: $ean is the sample EAN. #!/usr/bin/perl $ean = "9781565925212"; @factor = qw( 10 9 8 7 6 5 4 3 2 ); @remain = qw( 0 X 9 8 7 6 5 4 3 2 1 ); $check = 0; $ean =~ /978([0-9]{9})/; $isbn = $1; @temp = split //, $isbn; for($c=0;$c<9;$c++) { $check += $temp[$c]*$factor[$c]; } $check = $remain[$check % 11]; $isbn = qq/$isbn$check/; print $isbn; Thanks for the tip, Marc. -- Neil Williams ============= http://www.codehelp.co.uk/ http://www.dclug.org.uk/ http://www.isbn.org.uk/ http://sourceforge.net/projects/isbnsearch/ http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
Attachment:
pgp00041.pgp
Description: signature