Print

Print


Given a list of unique strings, how can I generate a list of short, unique integers?

I have a list of about 250 unique author/title combinations, such as:

  Aeschylus / Prometheus Bound
  Aeschylus / Suppliant Maidens
  American State / Articles of confederation
  American State / Declaration of Independence
  Aquinas / Summa Theologica
  Aristophanes / Achamians
  Aristophanes / Clouds
  Aristophanes / Ecclesiazusae
  Aristotle / On Generation And Corruption
  Aristotle / On The Gait Of Animals
  Aristotle / On The Generation Of Animals
  ...

From each author/title combination I want to create a file name (key). Specifically, I want a file name with the following form: author-firstwordofthetitle-integer.txt  Such a scheme will make it (relatively) easy for me to look at the file name and know the what title is and by whom.

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?

-- 
Eric Morgan