Here's my script:

#!/usr/bin/perl -w

#

# isbn_convertor - a tool to derive a pre-2007 10-digit ISBN

# number from a post-2007 13-digit ISBN number.

#

# The first three digits of the ISBN-13 number can be discarded

# but the last digit is a check digit computed from the

# rest of the number and this has to be re-calculated . . .

#

print "Give us the 13 digits, no spaces or dashes: ";

$isbn13 = <STDIN>;

chomp($isbn13);

#

# create a 13-element array from the input string:

#

@isbn13 = split(//, $isbn13);

#

# calculation of the check digit is explained at

#

http://en.wikipedia.org/wiki/Internatio ... ook_Number
#

$multiplier = 10;

for ($i = 3; $i <12; $i++){

$what = $isbn13[$i];

$product = $what * $multiplier;

$sum += $product;

--$multiplier;

}

$mod = $sum % 11;

$check = 11 - $mod;

if ($check =~ 10){

$check = 'X';

}

@isbn10 = @isbn13[3..11];

push(@isbn10, $check);

$asin = join("",@isbn10);

print "Your ASIN is $asin\n";

I've tested it with 14 books, I got one anomaly where I mistyped the ISBN for The Suspicions of Mr Whicher and got the ASIN for a different book although other mistypes returned errors from Amazon, I guess the check digit isn't infallible.