Print

Print


> Using Perl, how can I convert the author/title combination into some sort of integer, checksum, or unique value that is the same every time I run my script? I don't want to have to remember what was used before because I don't want to maintain a list of previously used keys. Should I use some form of the pack function? Should I sum the ASCII values of each character in the author/title combination?


Thank you for the prompt replies, and invariably I resolved my own question. Using Perl's unpack function I can generate a checksum based on the concatenation of the authors and titles:

  my $integer = unpack( "%32C*", "$author$title" ) % 65535;

The result is a unique four-digit number that will be consistently generated as my list of author/title combinations grows. At the same time, my solution looks much like an incantation -- with magic. Perl-specific and at a level of computing that is beyond my day-to-day understanding.

TGIF

-- 
Eric Morgan